by Doug Boude, CFUnited Correspondent
Any presentation of Joe Rinehart's automatically brings a certain level of anticipation and expectation. If you've been to any of his sessions in the past, you know Joe's style of always being well prepared, sharing well-thought-out analogies, the fast but digestible pace of information delivery, and personality. This session was no different, and every bit as satisfying and useful as others that I have attended in the past.
Joe got deep into his topic, delving into definitions of definitions at times, but never left his audience behind. In a nutshell, a design pattern is nothing more than a recurring concept that you find within your own approach to solving problems in code. In order to very clearly illustrate not only what design patterns are but also to show us real world examples, Joe introduced us all to Bob.
Bob is a coder. He built an application that uses a CFC to render the layout for his page (a genHeader method, genFooter method, etc.). Bob's boss was so impressed with Bob's application that he decided toresell it as a CMS! Good news. But not for Bob. Bob now had to find a way to elegantly switch between layouts, depending on which user is logged in. So Bob came up with a way to check the current user and, utilizing a CFSWITCH, select the appropriate CFC to instantiate. Okay, that problem solved! But Bob's boss kept adding requirements...the ability to switch between different looks and feel, different languages, and even different backend databases! Every one of these requirements were similar in nature to one another, and since the solution Bob devised to meet the first challenge worked so well, he used that same approach again for the subsequent, similar challenges. Guess what Bob was doing? He was recognizing challenges with commonalities and applying a common solution, a common Design Pattern. In this case, it just happened to be one encountered frequently by lots of coders, more commonly known as "The Simple Factory Pattern". Bob no longer shudders when his boss approaches with a design change; he's got the Simple Factory Pattern in his back pocket.
Joe spent time discussing several other common design patterns with us, using very simple and clear analogies to illustrate how they worked. Among this list were the Observer, Factory, and Facade Patterns.
In this correspondent's opinion, Joe Rinehart's expert guidance through the mysterious land of Design Patterns was flawless, and he undoubtedly did demystify the term 'Design Pattern'.
Having spent four years disarming bombs for the Air Force, Doug Boude is now a Senior Web Application Architect for Fiserv Health in San Antonio, TX. He has been developing with ColdFusion since version 4.0.