Designing object-oriented software is hard, and designing reusable object-oriented software is even harder. You must find pertinent objects, factor them into classes at the right granularity, define class interfaces and inherited hierarchies, and establish key relationships among them. Your design should be specific to the problem at hand but also general enough to address future problems and requirements. You also want to avoid redesign, or at least minimize it. Experienced object-oriented designers will tell you that a reusable and flexible design is difficult if not impossible to get "right" the first time. Before a design is finished, they usually try to reuse it several times, modifying it each time. Yet experienced object-oriented designers do make good designs. Meanwhile new designers are overwhelmed by the options available and tend to fall back on non-object-oriented techniques they've used before. It takes a long time for novices to learn what good object-oriented design is all about. Experienced designers evidently know something inexperienced ones don't. What is it?Read it over and over again to make sure you're taking it all in. This stuff is hard and you'll be overwhelmed at the beginning. It takes a lot of time and experience to get "good" and even the experts almost never get it "right" the first time, or even the first few times. Don't be discouraged but be realistic: don't expect OO to be a quick win. It's a process, a journey. I'd been doing OO for about three years before that book first appeared - imagine how frustrating those first three years were! Even after the book appeared, imagine how long it took people to come to terms with what the authors were saying and how much longer it took most people to take the contents of the book onboard! "Design Patterns" - Gamma, Helms, Johnson, Vlissides - ISBN 0201633612
Designing object-oriented software is hard
March 30, 2009 · 11 Comments
Ben Nadel had a bit of a "crisis of faith" last week over his ability to learn OOP the "right" way. He's highlighted a problem most people have coming to OO these days: in their search for the One True Way(tm), they are overwhelmed and can feel like failures. It can be a long, hard road. In a comment on his blog, I recommended everyone read the first two paragraphs of the "Gang of Four" Design Patterns book because it really sets this in context. I'm going to reproduce those first two paragraphs here to get you thinking. I highly recommend buying and reading the book.
Tags: architecture · coldfusion · programming

11 responses so far ↓
1 Ben Nadel // Mar 30, 2009 at 10:11 AM
Not to say that I want to go down that way, but that I need to dump this fear based thinking.
2 Sean Corfield // Mar 30, 2009 at 10:30 AM
3 Michael Long // Mar 30, 2009 at 12:51 PM
Where most developers get into trouble (IMHO) is that too many people have gone from treating patterns as food for thought to the software equivalent of tablets handed down from heaven, whose rules, etched in stone, must be followed to the letter at all costs.
They're not rules, they're more like guidelines... (grin)
The second thing is that too many people also believe that the holy grail of OOD lies in reuse.
It's not. Reuse is an important consideration, but above all OOD is simply a way to structure and incrementally built complex applications, as well as to "black box" various parts of the application from one another so that changes in module "A" won't break something in module "X".
The third thing to remember is that the ultimate goal of OOD isn't to do OOD simply for the sake of doing OOD. It's to quickly and easily create relatively bug-free applications for people to use.
4 Sean Corfield // Mar 30, 2009 at 1:04 PM
Your comment about reuse is particularly important since the vast majority of code we write is custom code and is never going to be reused. In many ways, OO is "just" an evolution of modular design, albeit on a finer-grained level, and an attempt to make software better "match" the domain that we are trying to work within.
It's also why, for example, BDD has such an emphasis on using terms from the business domain rather than lower-level terms from the (planned) implementation that is more common in TDD - even tho' both approaches are contingent on a tightly modular and generally OO mindset.
And, yes, each design pattern has DISadvantages as well as advantages. My point about tradeoffs and one that is continually omitted in most discussions (in the CF community).
5 ryan // Mar 30, 2009 at 2:07 PM
6 Adam Ness` // Mar 30, 2009 at 2:49 PM
I tend to take the Agile maxim of "Engineer the system for what you need now." to heart. Object Oriented development works great with that, because it breaks the problem up into smaller chunks, and if I need to later roll those chunks together, or split them apart, OO gives you models/tools to use to do that splitting and combining. Far too often, OO education though (at least in ColdFusion) is pitched in terms of "Use Gateways, Beans, and DAOs and MVC and voila! You're an OO developer."
OO is a lot more than just learning 3 or 4 patterns and calling it good. OO is really based on starting to think of your software as a system, composed of smaller systems, and thinking about how those systems interact with eachother. It's about drawing lines around piles of complexity, and trying to encapsulate that complexity. It's not a formula that can be taught, but rather a set of guidelines you can apply, which make code smaller, and easier to change, and more interesting to read.
7 John Farrar // Mar 31, 2009 at 5:19 AM
8 Rohit Channazhi // Apr 1, 2009 at 1:50 AM
9 james // May 22, 2009 at 6:54 AM
Right now, i'm wrestling with the boated service and anemic bean syndrome. Where is the best place to put bus. logic that deals with the bean? Too much in the service, not enough in the bean itself. Guidelines, not rules....ah yes....guidelines
10 Nathan Stanford II // Oct 2, 2010 at 12:04 PM
11 Sean Corfield // Oct 3, 2010 at 7:47 PM
Leave a Comment