start  find  index  login or register  edit  
20090713
by earl, 3873 days ago
You're writing "productiongrade" code for a large project and encounter the following problem. You have to encode (in C) a decision that somewhat naturally maps to:(x == 0 && y == 1)  "Naturally" means, if you consider and enumerate all valid possibilities, you'll get the above as result. ( x, y are integers >= 0 and p is simply a boolean predicate, the detailed structure of which is of no interest for the remaining discussion.)Well, after a short timespan of pondering this piece of code, you notice that it is equivalent to the following:
Question: which piece do you finally decide to keep? A few more bits of information: x , y , and p are expressions but are not very expensive to compute; you are also using a compiler that is sufficiently intelligent to avoid redundant calculations of those expressions. You have to comment the chosen piece in any case and phrasing the comment to reflect the structure of the code gives a readable and easy to understand explanation for both implementations.

search backlinks (more) none, yet recent stores (more) recent comments echo earlZstrainYattr ZY @.


earl.strain.at • esa3 • online for 6926 days • c'est un vanilla site 