Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are disadvantages of Abstract factory design pattern?

As usual to build the project with different design patterns, architects always prefer the advantageous view of that particular design pattern. But sometimes it need to understand what should be the violation area and disadvantages in terms of future extension of project. I am using Abstract factory design pattern now a days. I understood it but unable to figure out its disadvantages,its limitations, where it will get fail. can somebody please explain me this another view of Abstract Factory design pattern?

like image 439
Red Swan Avatar asked Oct 22 '13 04:10

Red Swan


1 Answers

First, with any design pattern you are adding more layers of abstraction and complexity, so only apply the pattern when the pain of not having it is apparent. This is a similar idea to Bob Martin's "Take the first bullet" and Nathan Marz' "Suffering-Oriented Programming."

With Abstract Factory in particular, the decision about which factory to use is made at runtime. Typically, this is done in some code dedicated to providing the right factory by conditional branching based on some key piece of information. This means as more factories are created, this central decision point must be modified. That's annoying.

Finally, if there are any changes to any underlying detail of one factory, the interface might need to be modified for all the factories. This breaks clients. So as usual, take great care with the choice of interfaces.

like image 176
Vidya Avatar answered Jan 02 '23 12:01

Vidya