Here’s a small step towards improving code legibility:
1) Formatting of code blocks
I prefer starting a new { on it’s own line and at the same indentation level as the statement above that starts the block.
if (1)
{
if (2)
{
print "2";
}
}
The popular style of putting the starting { at the end of the statement on the same line, while favored by many, I feel obscures code legibility. Some here may disagree with this.
2) Indentation
Most sources recommend against using tabs for indentation. I am guilty of using them, but I have to agree that for several reasons, spaces are better. People disagree on the ideal number of spaces for each indent level, but I think that 4 provides maximum legibility.
We should briefly debate these items and come to an agreement. Various styles are to be found within OpenEMR, even in the same file.
I don’t feel very strongly about it, but I often seem to write code with many levels of indentation, and normally use 2 spaces, or even just one! Usually I use single-space indents in JavaScript code, as the size of a JavaScript module has a significant impact on performance.