Feeds

Frameworks and the danger of a grand design

Hard-lesson learned

New hybrid storage solutions

It's probably safe to say that we've all succumbed to the "grand-design mindset" at one stage or another. It's a critical stage in a developer's growth: the dawning awareness that design matters, an earnest desire to write good code but without the bitter lessons that the reality of an over-designed project will soon fling at you.

The developer at this stage hasn't yet learned the hard way, that you can get too much of a good thing. This isn't really something that can be taught, at least not in such a way that it really drums the lesson home. You have to experience the pain of creating an over-designed "framework for the sake of it", believing in all good faith that your grand design will help, not hinder, maintainability.

The grand design mindset isn't just the application of an anti-pattern, or even just the inappropriate use of a normally well-behaved design pattern. The mindset is the overuse of patterns, carefully cementing nano-thin layers of indirection atop each other like a process in a chip fabrication plant that can't be shut down. It's the naïve belief that if X is good then 100X must be better every time.

Luckily this mindset is easy to spot. Your team members will be busy creating a beautiful but over-designed system with enums, annotations, closures and all the latest language features, loosely coupled classes and several hundred pluggable frameworks when a well-placed isThisTheRightValue() method would probably have sufficed.

Picture a pluggable framework that only ever has one plug. You'll see a comment in the code like:

    // Later this could be applied to other parts of the system. 

If there's neither time nor a compelling reason to apply the pluggable framework to other parts of the system in this iteration, then it's likely the programmer going off on a design pattern hike - exploring their talents - and the framework should be struck out of the code. It's just more complexity to maintain.

Of course, some programmers will never learn: they like writing code too much. Lots of it, as if they're paid in lines of code, or reviewed that way. Or maybe it's a macho thing. Pursuing your own grand design will do that for you, but it's better to solve problems with little code. Less is more.

Modern refactoring tools make it way too easy to fall into the "grand design" trap, with developers encouraged to develop the design as they're coding it. The refactoring tools are fast and sweeping. Radical design changes are just a keyboard combo away.

It's nice to think of refactoring as "redesigning at the speed of thought". But it isn't, it's refactoring faster than the programmer can think about the design and reflect on its implications for the rest of the system. The programmer is too immersed deep-down in the code to really appreciate the design from a higher level. So grand designs emerge before the programmer realizes it.

To develop their own design skills beyond the stage of the grand design, programmers must recognize that any time they're creating reusable code, they're writing a framework. It could be a modest one-class framework, or a system-wide thing of great complexity (like a data access object layer or presentation layer, for example). The developer must then also twig some important things about frameworks:

1. A bad framework is far worse than no framework at all

2. Good frameworks are hard to get right

3. You probably don't want to be writing your own framework anyway (or even seeking out a third-party one, for that matter)

Sometimes, specific, non-reusable code just hits the spot, because it gets the job done with a minimum of complexity. But sometimes, you do want code to be re-usable because you can see exactly where it'll be re-used. Having an overall design and an understanding of the broad set of requirements helps to identify whether re-usable code is needed.

But without stumbling upon this hard-earned lesson - without that Eureka! moment - the well-meaning developer will be stuck with a grand-design mindset forever.®

Matt Stephens is co-author of Use Case Driven Object Modeling with UML: Theory and Practice, which illustrates how to drive functional tests and unit tests from use cases, using the Spring Framework, JUnit and Enterprise Architect.

Reducing the cost and complexity of web vulnerability management

More from The Register

next story
New 'Cosmos' browser surfs the net by TXT alone
No data plan? No WiFi? No worries ... except sluggish download speed
'Windows 9' LEAK: Microsoft's playing catchup with Linux
Multiple desktops and live tiles in restored Start button star in new vids
iOS 8 release: WebGL now runs everywhere. Hurrah for 3D graphics!
HTML 5's pretty neat ... when your browser supports it
Mathematica hits the Web
Wolfram embraces the cloud, promies private cloud cut of its number-cruncher
Google extends app refund window to two hours
You now have 120 minutes to finish that game instead of 15
Mozilla shutters Labs, tells nobody it's been dead for five months
Staffer's blog reveals all as projects languish on GitHub
SUSE Linux owner Attachmate gobbled by Micro Focus for $2.3bn
Merger will lead to mainframe and COBOL powerhouse
iOS 8 Healthkit gets a bug SO Apple KILLS it. That's real healthcare!
Not fit for purpose on day of launch, says Cupertino
Profitless Twitter: We're looking to raise $1.5... yes, billion
We'll spend the dosh on transactions, biz stuff 'n' sh*t
prev story

Whitepapers

Secure remote control for conventional and virtual desktops
Balancing user privacy and privileged access, in accordance with compliance frameworks and legislation. Evaluating any potential remote control choice.
WIN a very cool portable ZX Spectrum
Win a one-off portable Spectrum built by legendary hardware hacker Ben Heck
Intelligent flash storage arrays
Tegile Intelligent Storage Arrays with IntelliFlash helps IT boost storage utilization and effciency while delivering unmatched storage savings and performance.
High Performance for All
While HPC is not new, it has traditionally been seen as a specialist area – is it now geared up to meet more mainstream requirements?
Beginner's guide to SSL certificates
De-mystify the technology involved and give you the information you need to make the best decision when considering your online security options.