Archive for the ‘ Book Club ’ Category

Technical Book Club: Object Oriented Analysis & Design, Chapter 1

So, as previously mentioned, we’ll start with the basics. This material is probably very familiar to most coders with even a small amount of experience, but it never hurts to refresh the fundamentals. You may even find that there’s some material that seems so obvious you don’t even actively think about it any more – which is good if it has become habit, but may be bad if you’ve grown complacent in certain areas.

The overarching theme of the first chapter is complexity. Complexity is the enemy of the software developer, and it is vital to understand this fact. If you don’t identify complexity as the enemy, you will find it harder to remain vigilant against it. 

Anyone who has worked as a developer for more than a year or two will almost certainly have exposure to the problems caused by complexity, but quite often complexity itself will not be pinpointed as the root cause. It may be a case of not seeing the wood for the trees – when trying to understand a system it’s very easy to get bogged down wondering why some particular section of code does things a certain way, and not see the problems with the big picture. Of course, since complexity obscures the big picture, this is common and self-perpetuating.

Object-oriented design, then, is a tool for managing complexity. Of course, it is many other things too, but this is one of the fundamentals. In particular, OOD is a natural way to represent hierarchies, and hierarchies are the primary tool Booch presents for making complexity manageable. A number of examples from nature are provided; for example, you can view a plant simply as a plant, or as a collection of structures (leaves, stem, roots).

Importantly, the overall hierarchical view of a plant can be broken down into many interacting sub-hierarchies, each of which may be considered in terms of its own structure and its interactions. This is an example of decomposition. If you want to study roots in detail, you can study the branch roots, the root apex, and the root cap – and break that down further if you like to consider roots as a collection of cells. To study roots in this sort of detail, however, you do not have to go to the same lengths with leaves and stems – it is enough to understand the interactions between the higher-level components.

Complexity, therefore, is more manageable if it is divided into interacting components, each of which can be further divided into interacting subcomponents. At different levels of abstraction there are clear boundaries – it shouldn’t be necessary to understand the epidermis of a leaf to examine a root, and likewise the study of a leaf should not need to consider the role of the root apex. This is known as separation of concerns, and allows you to ignore the parts of the system that you are not interested in at the time.

In software, these principles are captured by OOD. Broadly, hierarchies can be modelled with inheritance, components can be modelled with modules, intercomponent interactions can be modelled with interfaces and method calls, and intracomponent interactions can be modelled with aggregation. These interactions are key, as they form part of the ‘value’ of a system – in layman’s terms, the whole is greater than the sum of its parts.

Inheritance and aggregation are, respectively, ‘is-a’ and ‘part-of’ relationships. In both cases, these represent separate but overlapping hierarchies. Booch’s example is that of an aeroplane. An aeroplane can be thought of as an aggregation of systems – propulsion, flight control, etc. Each of those can potentially be modelled as specilaised types too – for instance a jet engine is a particular type of propulsion, and a turbofan engine is a particular type of jet engine.

In OO terms, the ‘is-a’ relationships are expressed as class structures utilising inheritance, and ‘part-of’ relationships are expressed as object structures utilising aggregation.

Relative primitives are an interesting concept, and refer as much as anything to the benefit of having a sensible and appropriate vocabulary at each level of abstraction. With plants, for instance, if you are working at the cellular level your primitives are nuclei, chloroplasts etc. If, however, you are at the top level your primitives should be leaves and stems – something is wrong if you are concerning yourself with the nucleus of a cell at this level of abstraction. Relative primitives are a natural consequence of hierarchies and decomposition, if your hierarchies are sane.

Even with all these tools for managing complexity at our disposal, it is still extraordinarily hard – if not nigh-on impossible – to construct a large complex system in one fell swoop. Booch identifies that a key characteristic of successful complex systems is that they evolve from simpler systems, whilst always being useful during that evolution – they have stable intermediate forms.

Contemporary development processes, such as agile development, explicitly recognise this with the mantra of ‘deliver early, deliver often’. The idea is that functionality should be delivered iteratively, with each iteration being functional and testable. This is in contrast to more traditional waterfall methodologies, which are notoriously associated with failed projects, often due to attempting to design a large complex system up-front and develop it all at once.

In summary, then, Booch argues that the characteristics of a manageable complex system are as follows:

  • Hierarchic
  • Uses relative primitives
  • Has robust separation of concerns
  • Has stable intermediate forms

It is important to note in passing that, since OOA&D is an unashamed champion of object-orientation as a mechanism for managing complexity, OO is by no means the only approach – functional and procedural languages have their own techniques, and in some cases may be more suitable, depending on the problem to be solved. Even so, many of these principles are common and are useful things to bear in mind when designing a system.

Next week we look at chapter 2, which covers the object model in greater detail.

  • Share/Bookmark

Technical Book Club

Back in October, personal finance blogger Trent at The Simple Dollar started an online book club for one of his favourite finance books. Good idea, I thought, so I’m nicking it. Starting in January, I’m running a technical book club at work with a few .Net devs, and I’ll write everything up and post it here, so if you’re so inclined you can follow along at home.

To start with, we’ll be reading language-agnostic books covering the fundamentals of software development in the real world, since it’s always valuable to refresh knowledge on the cornerstones of modern professional coding; later on this can diversify into specific technologies and subjects with more arcane, academic, or abstract overtones. Another benefit of starting with the basics is that we can concentrate on getting the format right without feeling overwhelmed by unfamiliar material.

So, the initial batch of texts will cover object-oriented design, design patterns, refactoring, code quality, and so on. Later, the idea is to study less immediate (but still vital) subjects like functional programming, compiler design, operating systems, etc.; and also to gain deeper knowledge of common specific technologies, e.g. the inner workings of the CLR or a JVM. I suspect people like stevey will argue that these latter subjects are more important than the others and should be done first, and they might even be right, but I’ve picked my approach and I’m sticking with it, so nuts to you stevey.

So, here’s the early schedule and probable books. The order we do these books might change – in fact the books themselves might change if, for example, we decide that Fowler’s Enterprise Patterns is more appropriate than the GoF’s Design Patterns. Each book will be agreed for certain in good time for it to be ordered and delivered before the scheduled start date, obviously.

Topic Book Start Date
OO Design
Object-Oriented Analysis and Design with Applications
14/01/2008
Design Patterns
Design Patterns: Elements of Reusable Object-Oriented Software
03/03/2008
Refactoring
Refactoring: Improving the Design of Existing Code
05/05/2008
Code Quality Pragmatic Programmer 07/07/2008
Legacy Code Working Effectively With Legacy Code 01/09/2008

In addition to these, we’ll also cover one chapter of Code Complete per week. So, there it is. If you want to tag along, get yourself a copy of Booch’s Object-Oriented Analysis and Design with Applications and McConnell’s seminal Code Complete, and tune in next month.

  • Share/Bookmark