Working with a stranger’s code..

Almost all the developers are given an opportunity everyday to work with stranger’s code which can sometimes become a dreadful experience which is when they don’t follow coding standards.

Coding standards is an essential part in a programmers life. It lets you work freely, letting you focus on the real work.

What happens when the developer doesn’t follow coding standards?

  • Nothing is standard i.e the code, the file system, file names and etc.
  • The developer will become a barrier in a team. More work for the other developers.
  • The developer will take more time to write less code.
  • The developer code will not generate standardized documentation.

What happens when the developer follow coding standards?

  • A standardized documentation can be generated. A standardized documentation helps new / current developers to contribute/modifying the the code.
  • The developer fits in the workflow of team without any hassle.
  • The developer will take less time to write more code.

Clients never stick to the original developer, the original developer can die, get sick or just get fired. If the original code is unstandardized, the following developer will take more time to do less work until it remains unstandardized.

There are a lot of ways to standardize code.

  1. Follow standards which are made by large organizations such as Pear, Drupal or Java / Modify the standards which are made by large organizations with your own coding style.
  2. Use doxygen, PHPDocumentor, JavaDoc and etc, tags on your comment blocks which will generate standardized documentation for the client.

I follow modified version of Pear Coding Standards with doxygen tags on the comment blocks.

  • Pear suggests 4 spaces of indentation, I use 2 spaces.
  • Pear suggest line length of 75-80 words, I completely ignore the line length idea unless asked to do so.

The coding standards shouldn’t be followed only when writing server-side scripts. You should use them when you are writing any type of code.