Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What is the structure of the web factory method

Shulou Source: shulou.com Published: 2022-06-01 03:39:51 09月26日 Update

This article introduces the relevant knowledge of "what is the structure of the web factory method". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Structure

From a class diagram perspective, both the factory method and the abstract factory class diagram have parallel product and creator (or factory) classes, except in the factory method pattern:

There is only one build method for each creator.

Creator will also have operations other than the build method.

There is only one set of ConcretCreator/ConcreateProduct as derived classes, which means that replacing derived classes is not the main purpose of this pattern.

6. Participant

Product (Document)

-defines the interface of the object created by the factory method.

ConcreteProduct (MyDocument)

-implement the Product interface.

Creator (Application)

-declares a factory method that returns an object of type Product. Creator can also define a default implementation of a factory method that returns a default ConcreteProduct object.

-you can call the factory method to create a Product object.

ConcreteCreator (MyApplication)

-redefine the factory method to return an ConcreteProduct instance.

The core participants of the factory method pattern are Creator and ConcreteCreator, which together with two Product make up the abstract factory pattern.

Collaboration

Creator relies on its subclasses to define factory methods, so it returns an appropriate ConcreteProduct instance.

For active or passive reasons, the Creator class delegates responsibility for building a product to a subclass.

This is the end of the content of "what is the structure of the web factory method". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Methods factories objects patterns structures two content participants only subclasses instances interfaces more knowledge different practical appropriate active learned and then Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei macOS NVidia Microsoft MySQL