Creating Poetry In Software
By Charles Connell
Some buildings are beautiful. They are easy to live and work in. They fit in well with the landscape. They are completed on time, for reasonable cost. And they look great. The beauty of these buildings is not just their appearance however. Their beauty also comes from how well they meet their purpose and solve problems posed by the site or the client.
The same is true for software. Some programs closely match their users needs, have few bugs, operate quickly, have modest cost, and are completed on schedule. Just like some buildings, these programs are beautiful. Their beauty comes both from how well they match their purpose and from their internal structure.
We would not accept a new house with sloping floors, holes in the ceilings, nails sticking out of the walls, and an outrageous price. Yet we often accept software in just such a state. We should be creating software that is beautiful, because aesthetically pleasing software works better and is less expensive. Software aesthetics includes the following general principles.
Cooperation -- Just as a building should be designed to blend with and enhance its site, software should work well with its surroundings. The "site" for a software system is its computer hardware, the operating system, other applications on the computer, and the style of the intended users. A recent example of software that cooperates with its environment is the appointment calendar built into the 3Com Palm products.
Appropriate Form -- The internal design of a software system should reflect and create its external functions. Beautiful buildings merge form and function, and good (beautiful) software does the same. An internal software structure that acknowledges the external features is more likely to create those features correctly. A software form that follows the software's function also is likely to be simpler, since the external features arise from the internal design rather than being forced on top of the design.
System Minimality -- Imagine a house built on a street that contains a public water supply and electrical service. Now suppose that the builders of the house dig a private well and construct their own power generating station. This extra work and expense in building a house would be unacceptable. Good building design keeps the building as small as possible, by using available external resources.
Beautiful software follows the same principle -- it is as small as it can be, by using existing computing resources where possible. It is the responsibility of every software architect and engineer to understand the computing system they are using, and to take advantage of its facilities whenever possible. Software should contain just what it needs to, and no more.
Component Singularity -- In general, beautiful buildings contain one room for each purpose. It would be exceedingly poor design for a house to contain four master bedrooms because the builders could not make any of them complete. In the same way, well designed software generally contains one instance of each component, and makes that component work correctly.
The opposite of singularity is redundancy, and is well recognized as poor software architecture. It is remarkable, however, how many software systems contain redundant code. In many cases, it is because one programmer does not know that another engineer already solved the same problem.
Functional Locality -- Good building design places related items together. The equipment and supplies for preparing meals usually are together in the kitchen. Plumbing, electrical and heating devices often are together in the basement. Good software design follows the same principal of placing related items together.
When software is constructed this way, it is easy for members of the project team to understand the software -- because the structure makes sense. It is easy to fix bugs and make changes -- because the relevant code is located in an obvious place. It is easy to replace an entire feature with a new approach -- because there is one distinct piece to replace.
Simplicity -- Software should do its work and solves its problems in the simplest manner possible. In many ways, simplicity is the most important principle -- and overlaps with all the other principles. Simple software is beautiful. Beautiful software is simple. Simple programs have fewer bugs (because there are fewer lines of code that can be wrong), run faster (because there are fewer machine instructions), are smaller (because there is less compiled code), and are easier to fix when broken (because there are fewer places where a bug can occur). Simple programs also are dramatically less expensive to create and maintain, for all of the above reasons.
Finally, there is a global quality to beautiful software that is not the sum of the previous attributes. Beautiful software is achieved by creating a "wonderful whole" that is more than the sum of its parts. Beautiful software is the right solution, both internally and externally, to the problem presented to its designers.
Biography: Charles Connell is president of CHC-3 Consulting Inc. in Woburn, MA (www.chc-3.com), which helps companies turn around troubled software projects.
(NOTE: This is the text of the article as submitted to the Boston Globe. The published version was shortened somewhat during editing.)