Rob Brooks-Bilson
Tech, Photography, Stuff
Tech, Photography, Stuff
November 8, 2004
I've been getting asked quite a bit lately about using Design Patterns in ColdFusion. It seems that a lot more people are reading up on them, but are often having a more difficult time figuring out both how and when to actually implement them within their ColdFusion applications.
I think it's important for developers to approach the use of design patterns not from a "which patterns can I use in my application", or "I want to use the strategy pattern in an application" approach, but rather from a solid architectural approach. That is, I think it's more productive for developers to first model their application, then look for patterns that help solve problems within that model. Of course in order to do this, you first need a good understanding of what the most common design patterns are, and how they
So, where does this leave us as ColdFusion developers? Most of the design pattern literature out there deals with implementing design patterns in languages such as C/C++, or Java, or sometimes even pseudo-code. That's ok if you understand those languages, especially if you are able to make the connection between how it's done in another language, and how that maps to ColdFusion and CFCs.
If you read the ColdFusion Developers Journal, you may have noticed that design patterns are being discussed in more and more articles. What i would suggest doing if you are interested in incorporating design patterns into your ColdFusion development is to purchase one of the popular design pattern books, and use it as a guide when reading some of the various ColdFusion specific design pattern articles. I think that taking this approach will allow a lot of ColdFusion developers, with no experience with other languages to make the most of the information that's out there, and to ease their way into the world of design patterns.
To get you started, here's an excerpt from the book Design Patterns: Elements of Reusable Object Oriented Software. This book, by the so called "Gang of Four" is considered the seminal work on software design patterns. The excerpt (chapter 1) is hosted on Macromedia's site and introduces Design Patterns and lists out some of the more common one's you are likely to encounter.
Once you have the introduction to design patterns out of the way, here are some of the ColdFusion design pattern articles worth taking a look at:
Template Method Pattern
Iterator Pattern
Strategy Pattern
Composite Pattern
More on Composition
More on Polymorphism
Singleton Pattern
Creational Patterns
Facade Pattern
Data Transfer Hash Pattern
If you couple these with one or more of the following books, I think you'll have a good starting point:
Headfirst Design Patterns
Design Patterns: Elements of Reusable Object Oriented Software (Gang of Four)
Design Patterns Explained: A New Perspective on Object-Oriented Design
I'd definitely like to see more design pattern articles focused on ColdFusion. If you would too, why not drop the ColdFusion Developers Journal editor, Simon Horwith, an email over at simon(at)horwith(dot)com and let him know you would like to see more coverage in the magazine.
11/9/04 10:24 AM
Although that is a great book and a must have, it's a horrible book to start with. It's more of a reference than anything else, and it is incredibly intimidating if it's your first foray into design patterns.
I highly, highly recommend Beginning Java Objects. Most people have an incredibly hard time just dealing with just one object, let alone a collection of objects, let alone design patterns.
11/9/04 10:30 AM
Thanks for the feedback ;-)
Which book is horrible one to start with? The Gang of Four book? If so, I'd agree. That's why I listed Headfirst Design Patterns first. I founf Head First Java to be an excellent book, and their design patterns book to be just as good.
Beginning Java Objects is another good one, and I should have included it in the initial list. I think the main point I was trying to make, though, was to get yourself several books, and read them in conjunction with the CF specific articles so that you can sort of "piece it all together".
I think one of the areas I could have done a better job with, though, was stressing that you really need to get yourself familiar with the concepts put forth in OO in general.
11/9/04 1:42 PM
Yes, I meant the GoF book. In fact, I recommend people don't even buy or even look at that book until they've used OO a little bit. It's a scary book :)
Oh, and the other two you listed are great as well. I especially enjoyed Design Patterns Explained.
11/18/04 6:56 AM
By the way you can get to my articles, builder.com's and Sean's but you can't get to Simon's without a subscription to CFDJ.
Brendan
1/10/05 9:15 AM
I have the "Gang of Four" book and have had a hard time with it. I'm interested in checking out the "Headfirst Design Patterns" and "Beginning Java Objects" books mentioned. Can anyone provide me the author names, or even better, the ISBNs?
Thanks!