Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Constance et qualité du code dans une équipe

Constance et qualité du code dans une équipe

Depuis plusieurs années, chez Mirego, nous recherchons constamment l’équilibre parfait entre la qualité des produits que nous bâtissons et celle du code qui les propulse.

Rémi Prévost

April 11, 2018
Tweet

More Decks by Rémi Prévost

Other Decks in Technology

Transcript

  1. { "type": "Program", "body": [ { "type": "VariableDeclaration", "kind": "const",

    "declarations": [ { "type": "VariableDeclarator", "id": { "type": "Identifier", "name": "foo" }, "init": { "type": "Literal", "value": "hello world", "raw": "'hello world'" } } ] } ], "sourceType": "script" } const foo = 'hello world';
  2. class ArticleFetcher { constructor(baseUrl) { this.baseUrl = baseUrl; } fetchArticles(sectionKey)

    { return fetch(this.baseUrl) .then(response => response.json()) .then(response => response.articles) .then(articles => articles.map(article => this.processArticle(article))); } processArticle(article) { const tags = article.sectionKey === 'sports' ? article.sportsTags : article.tags; return { ...article, tags: tags}; } }
  3. const extractTags = (article) => { return article.sectionKey === 'sports'

    ? article.sportsTags : article.tags; }; class ArticleFetcher { constructor(baseUrl) { this.baseUrl = baseUrl; } fetchArticles(sectionKey) { return fetch(this.baseUrl) .then(response => response.json()) .then(response => response.articles) .then(articles => articles.map(article => this.processArticle(article))); } processArticle(article) { const tags = extractTags(article); return { ...article, tags: tags}; } }
  4. storeLocale() { const result = []; if (this.isEnglish) { result.push('en');

    } else { result.push('fr'); if (this.isCanada) { result.push('ca'); } else { result.push('us'); } } return result; }
  5. storeLocale() { if (this.isActive) { this.locale = true; this.alternateLocale =

    false; return this; } } storeLocale() { if (!this.isActive) return; this.locale = true; this.alternateLocale = false; return this; }
  6. def store_locale(%{active: false} = thing) do thing end def store_locale(%{active:

    true} = thing) do thing |> Map.put(:locale, true) |> Map.put(:alterate_locale, false) end
  7. articleProxy(id) { this.fetch(id).then(a => { if (!a.isPublished) return; return {

    title: a.fullTitle, description: a.description.toUpperCase(), authorName: a.author.name }; }); }
  8. articleProxy(id) { this.fetch(id).then(article => { if (!article.isPublished) return; return {

    title: article.fullTitle, description: article.description.toUpperCase(), authorName: article.author.name }; }); }
  9. class FooComponent { handleFirstEvent(data) { this.data = data.toUpperCase(); this.name =

    'foo'; } } class BarComponent { handleSecondEvent(data) { this.data = data.toUpperCase(); this.name = 'bar'; } }
  10. class ParentComponent { setStuff(data, name) { this.data = data.toUpperCase(); this.name

    = name; } } class FooComponent extends ParentComponent { handleFirstEvent(data) { this.setStuff(data, 'foo'); } } class BarComponent extends ParentComponent { handleSecondEvent(data) { this.setStuff(data, 'bar'); } }
  11. alias Ecto.Query alias Accent.Endpoint alias Dataloader.Ecto alias GraphQL.Projects.Resolver alias GraphQL.Users.Resolver

    alias Web.Helpers alias GraphQL.Translations.Resolver alias Search.Configuration alias Absinthe.Plugin alias Accent.Repo alias GraphQL.Pages.Resolver
  12. alias Absinthe.Plugin alias Accent.Endpoint alias Accent.Repo alias Dataloader.Ecto alias Ecto.Query

    alias GraphQL.Pages.Resolver alias GraphQL.Projects.Resolver alias GraphQL.Users.Resolver alias GraphQL.Translations.Resolver alias Search.Configuration alias Web.Helpers
  13. import * as React from 'react'; import Button from 'material-ui/Button';

    import withStyles, {WithStylesProps} from 'material-ui/styles/withStyles'; import Zoom from 'material-ui/transitions/Zoom'; import {translate} from 'react-i18next'; import {compose} from 'recompose'; import AccentIcon from './components/accent-icon'; import {i18n} from 'i18next'; interface Props {}; interface TranslatedProps { i18n: i18n; } type EnhancedProps = Props & WithStylesProps & TranslatedProps;
  14. // Vendor import * as React from 'react'; // Vendor

    components import Button from 'material-ui/Button'; import withStyles, {WithStylesProps} from 'material-ui/styles/withStyles'; import Zoom from 'material-ui/transitions/Zoom'; import {compose} from 'recompose'; import {translate} from 'react-i18next'; // Components import AccentIcon from './components/accent-icon'; // Vendor types import {i18n} from 'i18next'; // Interfaces interface Props {}; interface TranslatedProps {i18n: i18n} // Types type EnhancedProps = Props & WithStylesProps & TranslatedProps;