I learned to program in C more than fourteen years ago. The first program that was taught in our class was the "hello world" program. It really had no practical use. I believe it was shown as an example to show the students the different parts of a program and how to compile and run it.
When I was learning the syntax and semantics of the language, I didn't really care how my program "looked". As long as it worked and solved the problem, I was happy and contented with it. My attitude was understandable given that I focused on finishing the programming task and solving the problem. Completing the problem was already hard so there was really no time left to think about whether the codes I've written were pleasing to me or to my teacher or to anyone else who would bother to read it. (I later realized that writing programs in "bad style" actually made the debugging harder.)
As I became more involved in programming, I was not just happy that my program worked according to the specs but also became concerned about its aesthetics. As I read the codes I have previously written, I discovered that if I've written it better, it would have been easier to understand and debug it. I also felt embarrassed about the codes and really didn't want to share it because it looked like the worst piece of code ever written.
Programming with style became more of a natural evolution for me. Little by little, I created "coding conventions" to make it easier for myself to understand the codes I've written. The conventions included several things such as formatting, variable naming, function naming, and file organization among other things. I believe it's part of being human to try to organize things to create order and understanding. Programming style is some sort of manifestation of this urge to create order and understanding. Don't you find it frustrating to read codes that have no apparent organization or order?
Friday, November 21, 2008
Subscribe to:
Post Comments (Atom)
1 comment:
But which is more important to you? following coding style or ensuring correct code?
Post a Comment