In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
What are the disadvantages of the abstract factory pattern? I believe that many inexperienced people are at a loss about this, so this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
The shortcomings of abstract factory model are as follows: 1. Adding new product grade structure is very complex; 2. Abstract factory and all concrete factory classes need to be modified, and the support for "opening and closing principle" is inclined.
Disadvantages:
Adding a new product hierarchy is complex, requiring changes to abstract factories and all specific factory classes, and support for the "open-close principle" is skewed.
Applicable scenario
You can use the abstract factory pattern when the object you need to create is a series of interrelated or interdependent product families. To put it more clearly, in an inheritance system, if there are multiple hierarchical structures (that is, there are multiple abstract classes), and there are certain associations or constraints among the implementation classes belonging to each hierarchical structure, you can use the abstract factory pattern. If there are no associations or constraints between the implementation classes in each hierarchy, it is more appropriate to use multiple separate factories to create the product.
Summary
Whether it is a simple factory pattern, a factory method pattern, or an abstract factory pattern, they all belong to the factory pattern and are very similar in form and characteristics, and their ultimate goal is decoupling. When using this pattern, we don't have to care about whether the factory method pattern or the abstract factory pattern, because the evolution between them is often elusive. Often you will find that the factory method pattern clearly used, when a new requirement comes and is slightly modified and a new method is added, it becomes an abstract factory pattern because the products in the class constitute product families in different hierarchical structures; for abstract factory patterns, when a method is reduced so that the supplied products no longer constitute a product family, it evolves into a factory method pattern.
Therefore, when using the factory mode, you only need to care about whether the goal of reducing coupling has been achieved.
After reading the above, have you mastered the disadvantages of the abstract factory pattern? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.