Home > In the moment > State of software development is broken: A pinhole view…

State of software development is broken: A pinhole view…

November 11th, 2011 Leave a comment Go to comments

…This is an account of some a personal experience and the trauma that follows….
A couple of weeks ago, I read something like this in a major piece of production code:

1
2
3
4
5
6
7
8
9
10
11
12
13
"]struct foo {
char a;
char *buf;
int flags; /* */
};
int some_function(struct foo *myfoo) {
...
size_t foosize = strlen((char *)myfoo); /* calculate the size to write */
...
fwrite(myfoo, 1, foosize, fp); /* fp was a file where the record was written */
}

Code snippet from production code that I had to “fix” 1

I had the distinct displeasure of running into the code snippet above.  Line 63 was the culprit code that was causing the customer intermittent issues.  What I find absolutely horrifying about this is that line 63 is not a subtle error buried in obscureness.  This use of strlen() is  scary because this kind of code disaster would never even enter the thought of a reasonable software programmer.  Yet here it was in all its hideous glory. What’s even more appalling is that this particular gem was produced by a team of so called software engineers that are graduates of good colleges and universities, and have been doing programming for several years.  As this  passed their unit tests, I am supremely scared to learn what else is going on in code developed by these folks that’s running out there.

One would think that this is a rare occurrence, and surely most coders wouldn’t code like this, I am afraid that the signs give an indication otherwise. Whilst I have not performed any empirical data analysis (may in a year), one can glean the trend from the type of questions asked and their answers on sites such as www.stackoverflow.com2 etc. that the state-of-the-art programming is on a terrible decline.

If this trend continues as is—and I am afraid it will unless something radical is done about it— we will have nothing but a fishnet for the proverbial water bottle in the stark dry desert that is our digital existence.

 


1 – If you want to know what the actual issue with this code is, I will discuss it as an addendum to this blog post later.

 

2 – Excellent forum for asking and getting answers to

 


References, Bibliography and Webliography

Some interesting posts on this topic are:

http://www.exmsft.com/~hanss/badcode.htm
http://www.codinghorror.com/blog/2006/05/code-smells.html

and of course the amazing WTF website at http://thedailywtf.com/

Categories: In the moment Tags:
  1. No comments yet.
  1. No trackbacks yet.