Coding Standards

From Teknologisk videncenter
Jump to: navigation, search

Remember: you shouldn't write source code just for yourself. What happens if someone else on the team needs to update it, while you're on the beach in Acapulco (or Aggersund)? Will your boss be pleased if you present unreadable code for the rest of the team to review? What if you have to make changes to code you haven't seen in the last six months? One of the most basic elements of good code layout is indentation, as discussed here:

The current author prefers Allman (and always has, before he found out that it is twice as popular as the second placed K&R = Kernighan and Ritchie in the above survey! ;-)).

The bottom line is: use a style (either because it suits you best or because you have been asked/told to do so) and use it consistently and always...

Other elements of coding style are also important. As a general and easily accessible example of coding standards see this: