The Artima Developer Community
Sponsored Link

Building Adaptable Systems
A Conversation with Andy Hunt and Dave Thomas, Part V
by Bill Venners
March 31, 2003

<<  Page 3 of 4  >>


Introducing Bugs by Making Code Configurable

Bill Venners:You say in your book, "Details mess up our pristine code—especially if they change frequently. Every time we have to go in and change code to accommodate some change in business logic or the law, or in management's personal taste of the day, we run the risk of breaking the system—of introducing a new bug." Is a system never broken by changing a configuration parameter? Are bugs never introduced by making code generic and configurable?

Dave Thomas: Sure they are. But first, we find that if a system is configurable, you typically end up with less code. Because the pieces are plugged together, you get a higher reuse of individual functions. Second, because you've designed it with configuration in mind, you tend to get cleaner designs that by their nature tend not to have as many bugs. The pieces are better decoupled. They have cleaner interfaces. They have stronger functions.

Andy Hunt: And you have fewer assumptions. Right out of the gate as you write the code, you know that you don't know what this value is going to be. You're getting it from the parameter file. The value is not hard-coded staring you in the face, where you might make some assumption like, "I know this will fit in a short," or "I know this is unsigned." You've already consciously admitted doubt. "I don't know what this is going to be." You are less likely to make any sort of assumption about what's coming in from the configuration file. You're more likely to code defensively.

Dave Thomas: But in reality, you get a different class of bug when you make systems configurable. Typically that comes about when a configuration exercises code in a different sequence from the way you anticipated it being used. And every now and then that hits you. The nice thing, though, is it's a real easy bug to find and test, because it's all controlled from an external configuration file. You just feed in a different set of parameters to the configuration, and you expose the bug.

Complexity of Configuration

Bill Venners: Does the complexity of configuration matter? Isn't configuration a kind of user interface? If I have a million configuration parameters, isn't that quite a lot for a user to deal with?

Dave Thomas: You have to be careful to distinguish between deployment and user options. Many Windows applications, for example, have a preferences or options box, which lets you set the color of this and the font of that. That's different from deciding whether I use CORBA or RMI to talk between the front and back end. That's not likely to be in a drop down list box somewhere. So there's developer-oriented deployment configuration, which tends to be more low level. You don't expose that to the user. You don't have to build the fancy user interfaces for the deployment options that you do for the user options.

<<  Page 3 of 4  >>

Sponsored Links

Copyright © 1996-2018 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use