Skip to content

Style guides

It is very useful to respect some norms and standards in your code, for various reasons, such as:

  • Better code readability: it becomes easier to write and to read the code
  • Better maintainability: having a more readable code is easier to modify if necessary
  • Better performances management: coding conventions allow a better optimization of the resources

Javascript style guide

If you are developing with Vue, you can use this .eslintrc.js configuration file.

You will find a file name CONVENTIONS.md in the various provided boilerplates. Hereafter are some of the rules we respect:

Block indentation: 2 spaces

We recommend that each time a new block or block-like construct is opened, the indent increases by two spaces.

Column limit: 120

We also recommend a column limit of 120 characters.

Arrow functions

When the body of an arrow function is a single line, we do not add unnecessary brackets or return statement.

YES:

javascript
  return this.contracts.filter(o => o._deleted !== true)

NO:

javascript
  return this.contracts.filter(o => { return o._deleted !== true })

Use single quotes

We recommend that ordinary string literals are delimated with single quotes ( ' ), rather than double quotes ( " ).

Exception: use double quotes ( " ) if the string contains a single quote ( ' ).

For example:

javascript
const steps = {
  Admissiblity: {
    id: 1,
    name: 'Recevabilité',
  },
  EvaluationSummary: {
    id: 2,
    name: "Dépôt d'avis",
  },
}

Naming events

We recommend to give events simple names that describe what is happening. For example: openDocument would be emitted when a document is actually opened.

Naming handlers

We recommend the handlers to begin with on. For example: onDocumentViewRequest().

If the code in the handler must be called by other parts of code, we extract the reused code into its own function. For example, the handler onDocumentViewRequest may call a method called openDocument(). No code should explicitly call onDocumentViewRequest.

Python style guide

In general, we refer to the style guidelines for Python defined in PEP 8.

We also recommend to use Flake8, which is a tool for style guide enforcement.

You will find a file named CONVENTIONS.md in the various provided boilerplates. Hereafter are some of the rules we respect:

Column limit: 120

We recommend a column limit of 120 characters.

Whitespace

We make an exception to PEP8 by preferring whitespace around all operators, regardless of priority. We find this approach to be both readable and consistent with rules applied in JavaScript.

YES:

python
END_OF_DAY = 3600 * 24 - 1
FOO = (1 + 2) * 3

NO:

python
END_OF_DAY = 3600*24 - 1
FOO = (1+2) * 3

Use single quotes

We recommend that ordinary string literals are delimited with single quotes ( ' ), rather than double quotes ( " ).

Exception: use double quotes ( " ) if the string contains a single quote ( ' ).

For example:

python
users = List(cls, part_name=String(description='Au moins trois lettres'), description="Utilisateurs d'Azure")
name = 'all_azure_users'

Next chapter

This clarified, we can go the next chapter, dealing with tools and technology.