-
As for the design pattern, simply put, it is a kind of architecture for the structure of the entire system when developing a large system, such as module division, hierarchy, etc., which is a high-level topic, which is done by software architects, and will not be understood without certain development experience.
-
There are also many common design patterns in software design, among which engineering mode, observer mode, and ** mode are used more. In general, there are 23 patterns involved in design patterns, which are generally divided into three categories: creative patterns, structural patterns, and behavioral patterns.
Among them, the creation mode includes five design patterns: factory mode, abstract factory mode, singleton mode, builder mode, and prototype mode. The structure mode includes 8 modes involved in the slag-based adapter mode, the bridging mode, the filter mode, the combination mode, the decorator mode, and the appearance mode, such as Sojin, Xiangyuan mode, and ** mode.
There are 12 design patterns, including chain of responsibility pattern, command pattern, interpreter pattern, iterator pattern, mediator pattern, memo pattern, observer pattern, state pattern, empty object pattern, policy pattern, template method pattern, and visitor pattern.
-
The design pattern principles are:
1. The principle of opening and closing: the expansion and the modification are closed, that is, when the program needs to be expanded, the original ** cannot be modified, and only a new ** can be added.
2. The principle of Richter transformation: the subclass inherits the parent class, and any place where the base class appears, it must be replaced by the subclass.
3. Dependency inversion principle: reference an object, if the object has a underlying type, directly reference the underlying type.
4. Interface isolation principle: It is better to use multiple isolated interfaces than to use a single interface, and each interface should be a role.
5. Synthesis Principle of aggregation and reuse: The new object should use some existing objects to make them part of the new object.
6. Dimmitt principle: an entity should interact with other entities as little as possible, so that the system functional modules are relatively independent, that is, an object should have as little understanding as possible about other objects.
-
The six principles of the design pattern are: the single responsibility principle, the open-close principle, the Richter substitution principle, the dependency inversion principle, the interface isolation principle, and Dimmitt's rule.
1. The principle of single responsibility: there should be no extra reason for the class change, that is, a class is only responsible for one responsibility.
2. The principle of opening and closing: a software entity such as classes, modules and functions should be expanded and closed.
3. Richter substitution principle: All references to the base class must be transparent to the objects of its subclasses.
4. The principle of dependency inversion: the high-level module should not rely on the low-level module, both should rely on its abstraction, abstraction should not rely on details, and details should rely on abstraction.
5. Interface isolation principle: the client should not rely on the interface it does not need, and the dependence of one class on another class should be built on the smallest interface.
6. Dimmitt's Law: Also known as the principle of least knowledge, it can also be expressed as an object should have the least knowledge of other objects, that is, a class should know the least about the classes it needs to couple or call.
The above content refers to Encyclopedia - Design Patterns.
-
The difference between a framework pattern and a design pattern.
The concepts of framework and design pattern are always confused, but there are differences between them. Frameworks are usually reused, while design patterns are design reuse, and architecture is somewhere in between, with some reuse, some design reuse, and sometimes analysis reuse. There are three levels of renegotiation in software production:
Internal reuse, i.e., abstract blocks that can be used publicly in the same application; Reuse, i.e. combining common modules into libraries or toolsets so that they can be used in multiple applications and domains; Reuse of application frameworks, i.e., providing a common or off-the-shelf infrastructure for a dedicated domain for the highest level of reusability.
Frameworks and design patterns, while similar, are fundamentally different. A design pattern is a description of a recurring problem in an environment and a solution to that problem, and it is more abstract than a framework; Frameworks can be represented by **, or they can be executed or reused directly, while for schemas, only instances can be represented by **; Design patterns are smaller elements than frameworks, which often contain one or more design patterns, and the framework is always specific to a specific application area, but the same pattern can be applied to a variety of applications. It can be said that the framework is the software, and the design pattern is the knowledge of the software.
-
The three categories of design patterns are composed of creative patterns, structural patterns, and behavioral patterns. Specifically, it is divided into 23 categories, which are as follows:
1. Creation mode: singleton mode, abstract factory mode, builder mode, factory mode, prototype mode.
2. Structural mode: adapter mode, bridge mode, decoration mode, combination mode, appearance mode, Xiangyuan mode, ** mode.
3. Behavioral mode: template method mode, command mode, iterator mode, observer mode, mediator mode, memo mode, interpreter mode, state mode, policy mode, chain of responsibility mode, visitor mode.
Depending on whether the pattern is mainly used for classes or objects, this mode can be divided into two types: class mode and object mode.
Class Pattern: Used to handle relationships between classes and subclasses, which are established through inheritance, are static, and are determined at compile time. Factory methods, (class) adapters, template methods, and interpreters belong to this pattern.
Object Schema: Used to deal with relationships between objects, which can be achieved by combining or aggregating, and can be changed at the time of operation, making them more dynamic.
There is no framework within Android for the time being.
It's good to do it yourself according to the principle of MVC layering, and some open sources like Facebook also have a lot of open source libraries. You can think about using it. >>>More
A template method pattern defines the skeleton of an algorithm in an operation, while deferring some implementation steps into a subclass. Template methods allow subclasses to redefine certain steps in an algorithm without changing the structure of the algorithm. >>>More
Recently I have seen a lot about the life of having fish. A wide variety of questions. In fact, this kind of question can be asked carefully by checking Life Youyu Zhiyuan. I don't know much, so I'll just talk about it briefly. >>>More
In the CDM project, the DOE's function is to carry out qualitative "validation" and quantitative "verification certification" of the CDM (Clean Development Mechanism) project. >>>More
Young man, are you sure you want to design? This one is very bitter, and you have to endure loneliness. Weigh for yourself.