Mittwoch, 29. Juli 2009

<Code Quality>

Today I came across a very nice drawing:


Thom is frakking right about it - in my opinion code normally falls into three categories:
  1. there is code that provokes no WTFs, because it is doing what it was intended to do in a very unspectacular way, self-documenting and as short as possible,
  2. then there is code that provokes only some WTFs, because it is mainly category #1 code with some passages where only few programmers can tell at first glimpse if it is pure awesomeness or complete rubbish (for example duff's device and its usage of intertwined switch and do-while statements vs. the infamous shortened XOR swap),
  3. finally, there is code that provokes a lot of WTFs, because it is so obviously wrong and ugly that almost anybody can see it upon first inspection.
Our goal as software engineers should be to write as much category #1 code as possible - and category #2 code only when it is absolutely neccessary, e.g. when one is forced to by performance and/or runtime constraints.

Keine Kommentare:

Kommentar veröffentlichen