21
Jun 06

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 :-).


21
Jun 06

World Cup Envy

If you ever thought the FIFA World Cup is irrelevant in the large scheme of things, think again: World Cup Envy.
(Via Martin Pittenauer)


06
Jun 06

Binary search is broken (most of the time)…

Very interesting gem on binary seaches.
(via Bill de hÓra).