In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Most people do not understand the knowledge points of this article "what are the advantages and disadvantages of web abstract factory pattern?", so the editor summarizes the following, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "web Abstract Factory pattern has its advantages and disadvantages" article.
Collaboration
An instance of the C o n c r e t e F a c t r o y class is usually created (unique) at run time. This specific factory creates product objects with specific implementations. In order to create different product objects, customers should use different specific factories.
There is something wrong with the translation of the original book. according to the following English text, the author adds a modifier "unique" here, which is more accurate. In addition, the so-called different product objects here should mean another group of product objects.
Normally a single instance of a ConcreteFactory class is created at run-time. This concrete factory creates product objects having a particular implementation. To create different product objects, clients should use a different concrete factory.
There is another problem. Here we are only talking about how it is usually done, not how it must be. The author believes that what I want to say here is that this is enough in most cases, rather than that this uniqueness is a necessary condition for abstract factory patterns.
AbstractFactory delays the creation of product objects to its C o n c r e t e Factory subclass.
The difficulty of this sentence is the understanding of the word "delay". Generally speaking, it is a normal step to create an object and then use it. But after using an abstract factory, Client can use the abstract factory interface to generate an object in its own code, and then use that object. It is only when this part of the code is actually executed that the concrete factory class is needed to create objects. This timing can be even after the release of the Client code.
Effect.
The A b s t r a c t F a c t o r y pattern has the following advantages and disadvantages:
1) it separates the specific class Abstract Factory schema to help you control the class of an object created by the application. Because a factory encapsulates the responsibility and process of creating product objects, it separates the customer from the implementation of the class. Customers manipulate instances through their abstract interfaces. The class names of the products are also separated in the implementation of the specific factory; they do not appear in the customer code.
2) it makes it easy to exchange a product family with a specific factory class that appears only once in an application-that is, when it is initialized. This makes it easy to change the specific factory of an application. It only needs to change the specific factory to use different product configurations, because an abstract factory creates a complete product family, so the entire product family changes immediately. In our user interface example, we just need to convert to the appropriate factory object and recreate the interface to achieve the transition from a M o ti f window component to a Presentation Manager window component.
3) it facilitates product consistency when product objects in a series are designed to work together, it is important that an application can only use objects in the same series at a time. A b s t r a c t F a c t o r y can easily achieve this.
4) it is difficult to support new types of products. It is difficult to expand abstract factories to produce new types of products. This is because
The A b s t r a c t F a c t o r y interface identifies the collection of products that can be created. Supporting new categories of products requires extending the factory interface, which will involve changes to the A b s t r a c t F a c t o r y class and all its subclasses. We will discuss a solution to this problem in the implementation section.
The first three are advantages, the problems that can be solved by using abstract engineering patterns, and the last one is disadvantages. Or the LED display screen in the previous article as an example: if you want to support the Font class separately, you need to add the corresponding createFont function to each factory class. It's troublesome.
About shortcomings
It is impossible for any method to have all the advantages and disadvantages, otherwise there will be no other methods in the world.
How to balance the advantages and disadvantages, and even enhance the strengths and circumvent the weaknesses, is the place to reflect the designer's ability.
The above is about the content of this article on "what are the advantages and disadvantages of web abstract factory model". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.
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.