Feeds

Building cohesion into programming

Time is of the essence

Reducing security risks from open source software

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. ®

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

More from The Register

next story
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
Mozilla fixes CRITICAL security holes in Firefox, urges v31 upgrade
Misc memory hazards 'could be exploited' - and guess what, one's a Javascript vuln
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
Google shows off new Chrome OS look
Athena springs full-grown from Chromium project's head
Apple: We'll unleash OS X Yosemite beta on the MASSES on 24 July
Starting today, regular fanbois will be guinea pigs, it tells Reg
HIDDEN packet sniffer spy tech in MILLIONS of iPhones, iPads – expert
Don't panic though – Apple's backdoor is not wide open to all, guru tells us
prev story

Whitepapers

Top three mobile application threats
Prevent sensitive data leakage over insecure channels or stolen mobile devices.
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.
Boost IT visibility and business value
How building a great service catalog relieves pressure points and demonstrates the value of IT service management.
Designing a Defense for Mobile Applications
Learn about the various considerations for defending mobile applications - from the application architecture itself to the myriad testing technologies.
Build a business case: developing custom apps
Learn how to maximize the value of custom applications by accelerating and simplifying their development.