Coding style

I usually edit more code others made, than I create new files, and while most of the code is in PHP, there’s a huge difference in the coding style applied by different developers, and some styles are much more annoying than others.

I do respect that people are different and that is probably more efficient to allow for some degree of personal style than to try to enforce a single common style. If possible try to make standards where all can agree upon them, and where it isn’t possible, don’t force it too hard (on less pressing issues makes it necessary).

While I don’t really believe in the enforced standardization, I do believe in one enforced principle – making your code manageable for others.

Leave reasonable tracks for others:

  • leave comments, where applicable (not too much tough).
  • Use consistent naming – for variables, functions, database tables and columns.
  • Make some high-level documentation (i.e.. in text-files next to the source code).

I really can’t of anything more annoying than a “treasure hunt”-style developer who’s abandoned code is inherited to me. The “treasure hunt”-style is easily recognized by:

  • A lot of files including other files (which includes other files which…)
  • No comments anywhere.
  • MVC-stye (especially a single controller file handling just about “everything”).
  • Inconsistent naming of variables (and functions).
  • Several class-layers and “generic” base classes, which is developed for a specific purpose.

I really don’t give credit for advanced code – I really love those who constrain their need to show off, and keeps the code neat, efficient and as simple as possible.