[Owncloud] Coding style

Diederik de Haas didi.debian at cknow.org
Sun Nov 11 19:18:40 UTC 2012


Hi,

Browsing through the code there are 2 things which surprise me.
1. Lots of values, which are actually constants, are typed as normal text.
Example: $_SERVER['REQUEST_METHOD'] == 'HEAD'

2. Formatting of the code is inconsistant.
Example: Some use 2 spaces for indenting, others 4 and others use tabs and 
according to checkstyle/Jenkins quite a lot of them are even 'wrong'.

Why is that, while afaik* there are easy solutions to that?
1. Define constants for values which are used more then once, like described in 
http://www.php.net/manual/en/language.constants.php#108717 of which I like the 
Constants class the best.
This makes (imo) the code more readable, less error prone, you can use 
'intellisense' to complete the code for you and it comforms to the DRY 
principle.

2. In Eclipse you can define a code style and with a press of a button/key-combo 
you can apply that style to the current page.
You can also export that definition so you can share it with others.
I would be surprised if that doesn't apply to other editors/IDEs as well.

Cheers,
  Diederik

* I'm a Java  developer with little to no experience with php



More information about the Owncloud mailing list