Monday, December 12, 2005

Coding Mistakes

I read an interesting article titled Coding Guidelines: Fact and Fiction this morning. Something interesting they brought up that I wouldn't think of in terms of 'coding guidelines' was the use of cognitive science in studying how we read and write code. A couple interesting terms:
  • knowledge failures - where developers don’t realize they have insufficient knowledge
  • performance failures -such as calculating an incorrect answer to a problem
The concept of knowledge failures is interesting to me. As I often maintain older code at my work this concept bites me time and time again. Now how does this fit into a coding guideline? Well the article goes on to say:
Possible solutions to knowledge-based mistakes include reducing the amount of information that developers need to know, or organizing the information contained in source code in such a way that there are fewer demands on developers to correctly recall or recognize information.
I see these mistakes made far too often. I'm working on a particular C based project and the bulk of the code is thrown into one large file with little care to even how it is ordered inside the file. Not to attack C code in general but I find this is the case more often with C code then some type of object-oriented code. I find coders who come from an OO background have distinctly greater desire to abstract and encapsulate code even when working with C. Two very important OO concepts that help drastically with the fight against knolwedge-based mistakes. Often OO coders spend the bulk of their time ensuring their code as an object makes sense, C coders spend their time managing memory and manipulating strings.

No comments: