Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Misused design patterns

Are there, in the canonical Gang of Four list, any design patterns that you often find misused, misunderstood or overused (other than the highly debated Singleton)? In other words, is there a design pattern you would advise to think twice before using? (And why?)

like image 257
Federico A. Ramponi Avatar asked Oct 30 '08 21:10

Federico A. Ramponi


People also ask

What is a common misuse of the facade pattern?

Common Mistakes while Implementing Facade Design Pattern Just naming a class as ABCDFacade. java doesn'r really make it a facade. Creating a java class and 'forcing' the UI to interact with other layers through it and calling it a facade layer is one more popular mistake.

Is design patterns is helpful or harmful for whom it is helpful or harmful?

They are not. They are ways to communicate and think about useful programming ideas.

What are design problems in design patterns?

The problem describes when to apply the pattern. It explains the problem and its context. It might describe specific design problems such as how to represent algorithms as objects. It might describe class or object structures that are symptomatic of an inflexible design.

What are the disadvantages of design patterns?

Disadvantages. Using design patterns requires extensive knowledge. Having design patterns available can also lead to people believing that apparently all problems can be solved using existing design patterns. In short, this can limit creativity and the desire to find new (better) solutions.


2 Answers

Factory Patterns...

I was parachuted into a project before where every single MyObject in the system had an equivalent MyObjectFactory for generating new instances. There was no concept of abstraction or extended classes... just plain old ClassX & ClassXFactory.

And no-one could explain why... "It was just the way things had always been done"

like image 164
Eoin Campbell Avatar answered Oct 02 '22 17:10

Eoin Campbell


The singleton pattern .. global state often leads to problems when testing

Any code depending on the singleton gets harder and harder to test because that dependency isn't easily mocked..

like image 40
Tigraine Avatar answered Oct 02 '22 18:10

Tigraine