I've been looking at a lot of very poorly written software lately and trying to figure out how to improve the process so that the problems I see don't happen again. The biggest class of problems are those things that are missing in the code, like reasonable logging. I've come to the conclusion that the software industry is missing something. That something is analogous to "The Building Code" in construction.
When we develop a piece of software, we go gather requirements from the users and start hammering out code. Everything is cool, right?
Not quite. There are many requirements the users know nothing about.
"Requirements the users know nothing about?"
Yep. Lots and lots of 'em. Let's jump into analogy to illustrate.
Suppose you are building a house. You decide you want a 4 bedroom 2-and-a-half bath ranch style house. You go to an architect, and he draws up a floor plan you really like, on a budget that, while more than you want to pay, you can live with.
As you examine the drawings you notice that there are a couple of pipes coming out of the main sewer lines and poking up through the roof. You didn't specify those! You ask the architect about them, and he replies, "Those are the stack vents; they're required by code." As you look closer, you notice more and more stuff, that you didn't request. Like electrical outlets every two feet along the kitchen counter top and every 12 feet around the perimeters of rooms. Like exhaust fans in bathrooms. Like windows big enough to exit through in bedrooms. Every time you question something you get the same answer "That's required by code."
You exclaim "What is this building code? Why do I have to follow it? It's making my house more expensive!"
The building code is a set of rules that new buildings must follow to insure that the building is durable and safe to inhabit. Some of the building code is there to insure that if the building does catch fire you can get out. Other parts of the building code are to prevent the house from catching fire in the first place. And yes, doing things according to code will make your house more expensive in the short term. However, if followed, it should keep the house from falling down in the first storm which would be much more expensive and potentially fatal.
Like building a house, there are many things that should be done in a production program that the user doesn't see, and doesn’t really care about. For instance:
Logging: Most programs in an IT environment should have configurable logging. The end users don't care (and won't specify that it be done), but the folks maintaining the system will need it to find the bugs that will appear.
Parameterization: If I had a nickel for every piece of code that had something hard-coded that should have been in a configuration somewhere I would have been able to retire in comfort some years ago. I've had numerous "programmers" argue that hard-coding it was "easier". And indeed it is as long as nothing ever changes. But since the only constant is change, hard-coding makes life much harder in the long run. I've seen one application that could not be sold, or even safely moved to a new environment because host names, user names, passwords, email address and, yes, even IP numbers were hard-coded into the application.
"But isn't this all common sense?" you ask, "Won't experienced people know all this stuff?"
Yes on both counts. But, unfortunately many people have no common sense and most IT organizations are not comprised of experienced, well trained people. And, since many of the "programmers" are sea-gull consultants
1, even if they have years of experience as consultants, they never live with the poor design decisions they make and therefore never learn from their mistakes.
Building codes would be unnecessary if everyone in construction was an honest trained architect/engineer (or even if they were under the direct supervision of an honest trained architect/engineer), but that isn't the case. There are many ignorant people as well as shysters and con-men posing as contractors. And there are many more posing as "IT professionals". The building code (and the permitting process in most places) catch many of the short-cuts and ignorance in building. We could use the same protection in IT.
Another reason that building codes are a good analogy is that they vary depending on the type of building. A dog house doesn't have the same codes
2 that a high-rise apartment building does.
In software we need the same flexibility. A three line shell script doesn't have the same requirements that a million line, three tier web application does.
"But my organization has these standards."
Great! However the rest of us may not. Actually that is how the building code evolved too. Each individual town/township/county/parish had, and usually still has, their own building code. But a larger common building code has since evolved from those smaller codes, taking the most sensible ideas from them. Most local codes are now based off of the standard building code (at least where I live).
3One of the other issues that comes up is the enforcement of the standards.
I'm currently working on a project where the standards are usually completely ignored. The reason is that the same group writing the software is responsible for monitoring the compliance with the standards, but there is no reason for them to comply. There are no consequences for non-compliance.
In this case we need an organization that does not report to the same management chain that reviews the code for compliance. An organization that has the power to send the code back to development.
I think, as an industry, we need to start laying down those common standards and the class of program they apply too in some formal way. That way we don't all have to re-invent the wheel.
What do you think?
1Sea-Gull Consultant: A consultant that flies in, makes a lot of noise, craps all over the place and then flies on to the next engagement and does the same thing.
2Or any building code requirements. Usually small (under 100 ft2) without plumbing or electricity are exempt from the building codes. And your dog probably isn't too picky either.
3My local county has adopted the "International 2006 Building Code."