Starter Step

Factory Pattern is tha Devil!

Posted on: January 16, 2009

I had to take a minute to write this one down…

I recently was training a group of folks on tdd and showing them some dependency injection techniques.  One of the techniques was how to break dependencies where the Factory Pattern was being used.  All was going well until the “tech lead” speaks up that “we should not be using the factory pattern” and continues to babble about how “j2ee discourages the factory pattern”.

Have I missed something? I of course told the guy I disagreed with him and could not understand why he would make that comment.  How could the Factory Pattern itself be “Evil”?

During this converstation, I had to bring up “Design by Difference” to this guy.  Remember that?  Yeah, that is the idea of creating a subclass to introduce new features.  You could see how potentially harmful it is to continually subclass in an inheritance hierarchy for adding new features. The pattern can do more good then bad when used correctly. How about the arguement of “singletons are evil” or “statics should never be used”.  These conversations make me want to hurl stones at people.  Is it too difficult to accept that these things are there for you to use and it is up to you to decide if it is the right tool for the job.

Meh! Why cant we all just use Ruby…

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


  • Dave: I can tell you're a ruby guy because you forgot the 'return' keyword. Thanks for the tip though!
  • Chandrashekhar H M: Hi, Thanks its working fine in iOS 6 but not in iOS 7.0. Any Suggestion on this.
  • Coeur: To change a rootViewController, without all this TVNavigationController : myNewRoot = [[UIViewController alloc] init]; myNavigationController.view
%d bloggers like this: