Page 1 of 1

Over-indenting is the enemy number one

PostPosted: 21 Feb 2013, 10:42
by Ursego
Indent code fragments with as few tabs as possible.

That will keep your scripts simple and easy to work with.

Usually, an indentation of 3 tabs says that the code could be written in a more elegant way, and an indentation of more than 3 tabs is a "red light" and signals about incorrect organization of code structure. Tab is like salt in a soup: it's a must, but over-use will make the product worthless. If your code has long "staircases" of closing braces (}) or END IFs (and other code-branching keywords) then it's a good idea to take your habits critically!

Try not to exceed 2 tabs. If you find yourself over-indenting your code, consider extracting the whole fragment into a new function (see Code after validations).

I remember the words of one of my first project managers: "If I see more than 3 tabs in your code, you are no more in the project!" :evil: ...