views:

236

answers:

4

Working with Java and Java frameworks I have started shuddering when I encounter Abstract Factory patterns. In my opinion this is the most abused design pattern. Not all frameworks abuse it but there are many. It doesn't fit all models and when almost 100% of the time you are going to be doing the same thing why abstract it?

Which design pattern in your opinion is the most abused design pattern? One where developer have used it but it doesn't fit the problem so well. A case of having a golden hammer and everything looking like a nail. So, which design pattern makes you shudder when you encounter it in the wild?

EDIT: Just thought about the Singleton. But that cropped up in the question of the most overused. I am asking for the most abused. (Or incorrectly used).

+14  A: 

Singleton, it makes it very difficult to unit test the code because it creates very strong references to other parts of the System.

Kalecser
That's why Spring rocks: singletons with DI. :)
cletus
Singleton = global (though sometimes you can't do without)
Anthony Rizk
+1. If you didn't say it first, I would have. I've seen whole programs composed of singletons. Yuck.
Eddie
A: 

In java I find that the template method pattern is used heavily. In most other languages it's almost an antipattern.

krosenvold
Is there a reason why it is considered an anti-pattern in other languages?
Mystic
See http://stackoverflow.com/questions/449731/design-patterns-to-avoid/449744
krosenvold
+2  A: 

I'd agree with Singleton.

But because people generally implement it as straight GoF vanilla and don't think about how it should be destroyed.

Have a read of the interesting chapter "To Kill A Singleton" also available in John Vlissides's book "Pattern Hatching: Design Patterns Applied" (sanitised Amazon link)

Edit: Just found the article "To Kill A Singleton" article on line here.

HTH

cheers

Rob Wells
A: 

I vote for Singleton as well.

I am not very fond of Singleton as it introduces dependencies that are hard to spot. A class may depend on a Singleton but you can not see it unless you read the code.

As already mentioned above this causes unit testing problems (among other things). The unit testing problems may be partly solved by using the Registry pattern instead of the Singleton pattern.

Jakob Christensen