??? 06/30/07 15:57 Read: times |
#141372 - Real Work vs. Fooling Around Responding to: ???'s previous message |
Andy said:
Be explicit with your code, use parentheses liberally, and don't use the clever tricks K & R show you.
You'll understand your code in six months, the compiler will do what you expect, stepping through code in the debugger is a lot easier, and everyone will be a lot happier when it just works. I think we need to make a distinction between "real work" and "fooling around". When you're doing real work, I agree with you 1000%. However, I also see some value in little recreational programming puzzles that challenge your creativity and encourage you to try various things that you wouldn't dare to put in a "real" program. I know I've learned a lot over the last few months from the little quizzes and puzzles that have appeared on this site. Just as an example, consider Chris's comments on operator precedence and the use of parentheses. In real work, I agree with you that you should use parentheses liberally in order to make your intentions explicitly clear, not so much for the benefit of the compiler (which has the operator precedence rules down cold!) as to help the next poor clown who has to maintain your code. If doing so "dumbs you down", as Chris put it, then the occasional challenge of puzzles like this one, where parentheses have an artificial cost, can serve to reverse the effect. IMHO, anyway. -- Russ |