Menasoft Menasoft Menasoft Menasoft Menasoft
Menasoft
Menasoft

April 14, 2006

Enforced coherent coding standards

I could go on all day about this one. I just had to start a thread on it. There is a proliferation of poor code in the world. I’ve recently had opportunity to see some potentially horrendous examples of code used in actual commercial products. (no names will be mentioned).

There are of course many ideas about how strictly managers should enforce coding standards. One extreme is that style is just a matter of taste and nothing matters except testable results. i.e. If the code passes unit tests and functional tests, then that’s good code.

Needless to say I disagree… I think style = maintainability. One day the person that created this code will be gone. Someone else will inherit it. The faster that person can look at and understand the flow of that code the better.

Here are some things I’ve seen in code I’ve inherited:

1. Lack of in code comments. Definitely THE number one problem. I’m amazed at how often i see code with not one single comment. I have no idea what the writer was thinking.
2. Lack of updating of in code comments (the comments that did exist where often out of date or unintelligible)
3. Magic numbers in the code for things that should have been shared symbolic constants.
3. Multiple definitions of symbolic constants
4. Duplication of code. The same code cut and pasted into some other module. This is what functions are for !
5. No functions naming conventions. Names as descriptive as foo() are not uncommon. C++ helps this a little bit in that things tend toward logical grouping. Names should AT LEAST be descriptive.
6. Spaghetti threads. Threads of execution in totally inappropriate places. jumping all around.
7. Dead code. When code becomes old and un-loved. There are some threads that are never even possible. Only proper understanding of the code, profiling (code coverage) or cross referencing will find these.

One conclusion I can draw from this is that this was un-loved code. Programmers just aren’t taking pride in their work ? There are 2 models I’ve seen that have worked for code development.

1. Several peer engineers that each owned and “loved” there little piece of code. as engineers moved to other jobs or projects. The code baton was handed off to the new owner. This involves maybe even weeks of working closely with the previous engineer.

2. Managed software group. Coherent coding standards where created and ENFORCED. This could be by peer review and just single manager review. In either case it is mandated by management.

Filed under: Philosophic — admin @ 3:49 pm

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Time limit is exhausted. Please reload CAPTCHA.

Menasoft