Today is a good day to code

Abstract Factory Pattern

Posted: December 31st, 1969 | Author: | Filed under: Uncategorized | No Comments »

Abstract Factory Pattern

Picture of Irv Owens Web DeveloperOn Sean Corfield's blog earlier today I read his discussing of the appropriateness of using the abstract factory design pattern. I'd agree that the Abstract Factory pattern is indeed overkill for ColdFusion almost all the time.

I'd even go as far as to say that the factory design pattern is probably overkill for many ColdFusion applications. While it is really cool and most people who learn object oriented techniques long to use it, it really isn't necessary in most web applications. Most of the time it will make your code very hard to read as you will have possibly thousands of low level objects, and very long XML files to provide configuration information to your factory objects. It does go a long way to code reuse, you could then make all of your components very generic, and could put them in almost anything.

Still, all that being said about how cool the factory patterns all, they really shouldn't get much use in day-to-day application development. Usually when building a ColdFusion application, you aren't going to have to interface with Java, or even legacy ColdFusion code. You probably won't have to build a system that will have thousands of developers working on it simultaneously. While it would be nice to have companies looking to ColdFusion to do these types of things, it hasn't been the norm. If you happen to be working on this type of project, then Mach-ii and model-glue are probably the way to go. The overhead introduced will be minimal compared to the heavy lifting that the application is expected to do anyway. If you are working on a simple blog site then you wouldn't want to invoke the entire design pattern apparatus. Even the GOF were pretty clear about this. Don't overengineer. If you want to be a true programming hero, deliver solid solutions on time. Steve Jobs said it best, “Real Artists Ship.” Ain't that is the truth.

I am seeing more and more people using sledgehammers in programming to kill gnats. Just because servers have gotten so fast they can handle the massive amounts of junk code they are being fed doesn't mean that developers should squander resources. You never know when those resources will be needed either by an enhancement to your application, or an application built by someone else on the same server. You never want for the problem to come back to your code.