Feeds

Building cohesion into programming

Time is of the essence

3 Big data security analytics techniques

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

Top three mobile application threats

More from The Register

next story
This time it's 'Personal': new Office 365 sub covers just two devices
Redmond also brings Office into Google's back yard
Inside the Hekaton: SQL Server 2014's database engine deconstructed
Nadella's database sqares the circle of cheap memory vs speed
Oh no, Joe: WinPhone users already griping over 8.1 mega-update
Hang on. Which bit of Developer Preview don't you understand?
Microsoft lobs pre-release Windows Phone 8.1 at devs who dare
App makers can load it before anyone else, but if they do they're stuck with it
Half of Twitter's 'active users' are SILENT STALKERS
Nearly 50% have NEVER tweeted a word
Internet-of-stuff startup dumps NoSQL for ... SQL?
NoSQL taste great at first but lacks proper nutrients, says startup cloud whiz
IRS boss on XP migration: 'Classic fix the airplane while you're flying it attempt'
Plus: Condoleezza Rice at Dropbox 'maybe she can find ... weapons of mass destruction'
Ditch the sync, paddle in the Streem: Upstart offers syncless sharing
Upload, delete and carry on sharing afterwards?
New Facebook phone app allows you to stalk your mates
Nearby Friends feature goes live in a few weeks
prev story

Whitepapers

Top three mobile application threats
Learn about three of the top mobile application security threats facing businesses today and recommendations on how to mitigate the risk.
Combat fraud and increase customer satisfaction
Based on their experience using HP ArcSight Enterprise Security Manager for IT security operations, Finansbank moved to HP ArcSight ESM for fraud management.
The benefits of software based PBX
Why you should break free from your proprietary PBX and how to leverage your existing server hardware.
Five 3D headsets to be won!
We were so impressed by the Durovis Dive headset we’ve asked the company to give some away to Reg readers.
SANS - Survey on application security programs
In this whitepaper learn about the state of application security programs and practices of 488 surveyed respondents, and discover how mature and effective these programs are.