Feeds

Building cohesion into programming

Time is of the essence

The Power of One Brief: Top reasons to choose HP BladeSystem

The advice to take away is that organising with respect to rate of change is a form of cohesion that can improve the stability of individual abstractions and stabilise the dependencies between them (hence the reason that these have been termed the Stable Abstractions Principle and the Stable Dependencies Principle).

What happens if you apply these principles consistently and in the large? Above the level of individual classes and packages, across a whole system, the result is a layered architecture whose layers are related by rate of change (the Shearing Layers pattern describes this in detail, relating it to a similar observation about building architecture). Rate of change often aligns with other layering criteria, such as layering of kinds of abstractions, separation of technologies, grouping of developer skills, organisational structure, etc, allowing the same design to be reached and supported by different lines of reasoning.

So, how do you design a system so that it is organised with respect to rate of change? The empirical answer is that you observe the change and respond accordingly, using refactoring as the means by which you let volatile elements bubble up and stable elements sink through the layers. Iterative development lifecycles offer a useful cyclic timeline against which stability can be assessed. Reports on relative stability can be made against source code version history. From a micro-process perspective, Test-Driven Development also offers useful feedback.

It is also possible to be proactive in trying to establish an architecture based on stability. There are a number of established design practices that promote partitioning styles that are already in tune with this idea. For example, separating the things that change from the things that do not is a recurring theme in many descriptions of polymorphism.

The Gang-of-Four's advice to "program to an interface, not an implementation" encourages a style of class hierarchy design that ensures that the root of a hierarchy is as stable as possible. Having only a pure interface at the root of a hierarchy, rather than a mix of interface and implementation, ensures that the root of the hierarchy (and its dependents) removes any instability that arises through changes in implementation at the root level.

This OO approach of separating interface from implementation is normally motivated as an extension of information hiding, which in turn is normally associated with the concept of modular design.

Although David Parnas was not responsible for coming up with the concept of the module, he was responsible for promoting the concept and encouraging a reasoned approach to modularity. If we look closely at the original motivation for information hiding, we find that we come full circle back to the notion of designing in terms of stability. The whole point of introducing separations and boundaries was to deal with "difficult design decisions or design decisions which are likely to change", partitioning so that "each module is then designed to hide such a decision from the others".

So, what then is cohesion all about? It's all about time. Build times, stability over time, and the time taken to understand a piece of code are all related. ®

Seven Steps to Software Security

More from The Register

next story
Secure microkernel that uses maths to be 'bug free' goes open source
Hacker-repelling, drone-protecting code will soon be yours to tweak as you see fit
KDE releases ice-cream coloured Plasma 5 just in time for summer
Melty but refreshing - popular rival to Mint's Cinnamon's still a work in progress
NO MORE ALL CAPS and other pleasures of Visual Studio 14
Unpicking a packed preview that breaks down ASP.NET
Cheer up, Nokia fans. It can start making mobes again in 18 months
The real winner of the Nokia sale is *drumroll* ... Nokia
Put down that Oracle database patch: It could cost $23,000 per CPU
On-by-default INMEMORY tech a boon for developers ... as long as they can afford it
Another day, another Firefox: Version 31 is upon us ALREADY
Web devs, Mozilla really wants you to like this one
Google shows off new Chrome OS look
Athena springs full-grown from Chromium project's head
prev story

Whitepapers

Implementing global e-invoicing with guaranteed legal certainty
Explaining the role local tax compliance plays in successful supply chain management and e-business and how leading global brands are addressing this.
Consolidation: The Foundation for IT Business Transformation
In this whitepaper learn how effective consolidation of IT and business resources can enable multiple, meaningful business benefits.
Application security programs and practises
Follow a few strategies and your organization can gain the full benefits of open source and the cloud without compromising the security of your applications.
How modern custom applications can spur business growth
Learn how to create, deploy and manage custom applications without consuming or expanding the need for scarce, expensive IT resources.
Securing Web Applications Made Simple and Scalable
Learn how automated security testing can provide a simple and scalable way to protect your web applications.