Skip to content
This repository has been archived by the owner on Sep 23, 2023. It is now read-only.

Coding guidelines

Olivier Paroz edited this page Oct 14, 2015 · 8 revisions

In General

Make it easier to review

Naming

  • Use meaningful method and variable names
  • Keep referring to media types as mimetype, so that people woring on core understand what it means

PHP

short-circuit evaluation

PHP uses a short-circuit evaluation technique when looking at conditions

if (conditionA && conditionB)

If conditionA is false, conditionB will never be tested.

Cache

When searching in a storage's cache, you can't limit the scope to a specific path, the cache will look in the entire storage.

Javascript

Be very careful when working on the slideshow as the code and the CSS is being injected in the Files app and there could be side effects. Use the proper namespace and encapsulation.

Translations

Concatenated string cannot be processed by the l10n tools

Wrong

t('gallery',"This is my very long" +
" string, that I want to split");

Correct

t('gallery',"This is my very long string, that I want to split");