On code formatting issues

Jeff Atwood wonders:

The code formatting, as promised, is pretty. But the emphasis on formatting does make me wonder– rather than focusing on the external, cosmetic attributes of the code, shouldn’t we be searching for something prettier on the inside? Such as a higher level language?

I used to be a code formatting fetishist. I remember spending ages on nicely formatted parameter lists, comments etc. Not to mention the dreaded pascal.h incident. About 20 years later, I find:
Placement of curly braces is really relevant if the while loop in question includes multiple nested if’s and thus spans several pages. But if this very same piece of code is properly refactored, it’s probably a collection of very brief functions/methods & classes. Now the functions are short and to the point – and the code’s formatting doesn’t really matter that much anymore. Who cares where the curly braces are if the method is about 7-10 lines?
If the code’s formatting is consistent, the code is properly refactored and functions, classes & variables names precisely reflect the concepts they represent – what more can you ask for? The real beauty comes from within: The structure of the code.
(BTW, it took me years to come to that conclusion – and, from time to time, I still reformat legacy code I work with – old habits are hard to break :-).

Comments are closed.