Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the relevant knowledge points of web Creative Model

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "what are the relevant knowledge points of web creation mode". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the idea of Xiaobian and go deep into it slowly to study and learn "what are the relevant knowledge points of web creation mode" together!

Discussion on Creation Pattern

Consider the Drawing Editor framework described in Prototype mode. There are several ways to parameterize GraphicTool with product classes:

Consider a scenario where graphic features are added to the system through a palette.

·Using Factory Method mode, a subclass of GraphicTool is created for each subclass of Graphic in the selection palette. GraphicTool will have a NewGraphic action, which will be redefined by each subclass of GraphicTool.

As explained in the Prototype Mode section, GraphicTool class has additional functions, such as graphic movement and rotation. This should be the basis for building another GraphicTool subclass.

·With the Abstract Factory pattern, there will be a GraphicsFactory class hierarchy corresponding to each subclass of Graphic. In this case only one product is created per factory: Circle Factory will create Circle, Line Factory will create Line, and so on. GraphicTool takes as parameters the factory that creates the appropriate kind of Graphic.

The approach here is to build a scenario of one product per plant. In actual development, it is also possible to add parameters to the factory method of building the product, which can effectively reduce the number of factories or factory methods.

·Using Prototype mode, each subclass of Graphic will implement Clone operations, and Graphic cTool will take as parameters the prototype of the Graphic it creates.

This is the approach chosen in the Design Patterns book.

Which model is best depends on many factors. At first glance, FactoryMethod mode is the easiest to use in our drawing editor framework. It is easy to define a new subclass of GraphicTool, and instances of GraphicTool are created only if the selection board is defined. Its main drawback is the proliferation of GraphicTool subclasses, none of which do much.

Factory methods are supposed to be a sideline, adding ways to build related products to an existing class to make it a host class, but in practice it often happens that new subclasses are built just to add new products. That's a bit much.

Abstract Factory isn't much of an improvement because it requires an equally large Graphics Factory class hierarchy. Abstract Factory is only slightly better than Factory Method if a GraphicsFactory class hierarchy already exists-either because the compiler provides it automatically (as in Smalltalk or Objective C) or because other parts of the system require it.

In a way, abstract factories are just new classes that separate factory methods from host classes, so they have similar problems with factory methods.

Overall, Prototype mode is probably best for the Drawing Editor framework because it requires only one Clone operation per Graphics class. This reduces the number of classes, and Clone can be used for other purposes than pure instantiation (e.g., a Duplicate menu action).

In other words, archetypal patterns are best suited for archetypal scenarios. This is of course the case, otherwise the prototype mode would not have chosen this scenario. When using prototype patterns in actual development, there is no escaping the question of where the prototype comes from.

Factory Method enables a design to be customized with only a little complexity. Other design patterns require new classes, while Factory Method requires only one new operation. Factory Method is often referred to as a standard way to create objects. But this is not necessary when the instantiated class does not change at all or when instantiation occurs in operations where subclasses can be easily redefined, such as in initialization operations.

If you need to separate out the code that builds the product, the factory approach can be used as a first step. If there is no need to change the type of instantiation, or if the type change can be synchronized with the polymorphism of actions, there is no need to separate the parts that build the product.

Designs using Abstract Factory, Prototype, or Builder are even more flexible than those using Factory Method, but they are also more complex. Often, a design starts with Factory Method, and evolves toward other creation patterns when designers find that more flexibility is needed. Knowing multiple patterns gives you more options when you weigh between design criteria.

More independent classes mean more flexibility, but they also mean more complex designs. This is a test of the designer's ability to choose, the sense of balance. Of course, as a prerequisite for choice and balance, you need to know what design patterns are available.

Thank you for reading, the above is the content of "what are the relevant knowledge points of web creation mode", after learning this article, I believe that everyone has a deeper understanding of what are the relevant knowledge points of web creation mode, and the specific use situation needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report