Bottom-Up Design

by Krishna on April 29, 2011

The strangest thing I have read in the recent past (emphasis mine):

In his classic “Clean Code” Robert C. Martin describes a great (and widely adopted) way to object oriented programming. He says code should read from top to bottom like prose. Start with the most high-level concepts and break them down into lower-level pieces. Then when you work with such a source file, you may be able to more easily follow the flow and understand how it works.

I am not sure if Bob Martin actually said that, but for as long as I can remember, object-oriented programming was meant to be bottom-up design. OO design was supposed to be a relief from the top-down programming of procedural languages such as Basic and C, where you start with the problem that you need to solve and then break it into tiny pieces of functionality. In OO design, you think at the lowest level about objects that interact with each other and define properties and methods. Then you assemble them together to gain the desired functionality in your program.

The comparison here is to assembly lines. You take various components and then assemble them together to obtain the final product (car, truck or airplane). In object-oriented design, we want to gain the same advantage. Of course, the problem is that programming is not exactly like manufacturing, and traditional object-oriented languages have been found lacking. Hence continued innovation in the programming language space. We have been seeing new languages as well as dramatic improvements in existing languages (C# comes to mind).

As for the rest of the piece, there is weird stuff like “It takes some training to learn how not to write 2000-line classes and 500-line methods”. But this even violates top-down design. A 500-line method is not broken down into “lower-level pieces”. Someone who does that has no concept of code organization, reuse and maintainability. It is not an effect of OO programming, as the author seems to imply.

{ 2 comments }

joseph palmer April 29, 2011 at 9:37 pm

That is something that makes me think and helps, like the assembly line analogy!

Christian Schlichtherle May 6, 2011 at 8:06 am

I think you must have missed something. Modern OO design is neither top-down nor bottom-up. If at all, it's evolutionary starting from a small subset of the desired features, applying design patterns and refactorings to work towards an architecture which is extensible. The whole process should be managed by some design method like XP or similar.

Comments on this entry are closed.

Previous post:

Next post: