- I find it makes the code more readable.
- Highlights when there is a lot of nested code, that might or should be refactored.
- It is consistent with C#, I know you can also change the number of spaces for tabs in C#, but 2 spaces in C# looks wrong to me.
Wednesday, 7 December 2016
4 space indent vs 2 space indent
Some developers like 4 spaces for the indent and some like 2 spaces. Originally I preferred 2 spaces, but ended up working for a company that insisted on 4 spaces, which is understandable to keep code consistent. And after using a 4 space indent for 5 years I actually prefer it for the following reasons:
Subscribe to:
Post Comments (Atom)
it was always 2, and should be 2 (IMHO). for other languages (C#, Python, SQL, etc) their standards should apply. don't try to fit your identation for all languages. be flexible.
ReplyDeleteThe default now for C# and MS SQL Server is 4 spaces, but is still 2 spaces for the Delphi source (System.Classes.pas). You say to be flexible and I agree that would be nice, however consider how you would write this in the coding standards for a company when you need to be consistent. Maybe the answer is to follow what the default is for the source, this would then also end the argument of where the 'begin' should be, one the same line (Egyptian style) or on a new line (as the source code).
ReplyDelete>don't try to fit your identation for all
ReplyDelete>languages. be flexible.
The problem is that today most people use more than one language. Just as all IDEs (except Delphi's) allow you to change all of the key bindings so that you can have a consistent set of keyboard commands across IDEs and applications, it can be useful to implement a consistent style guide across languages one uses (so long as it isn't radically at odds with established norms for that language).