Overview of the "OOAD" design pattern

Source: Internet
Author: User

    • The birth and definition of the pattern

The model originated from the construction industry rather than the software industry
The father of patterns (pattern)--Dr. Christopher Alexander, director of the Institute of Environmental Architecture, California University, USA
"A pattern language:towns, buildings, construction"--253 architectural and urban planning models
Mode
Context (pre-requisites for pattern applicability)
Theme or problem (target problem to be solved under certain conditions)
Solution (description of various physical relationships in the process of solving the target problem)

Alexander gives a classic definition of the pattern: Each pattern describes a problem that continues to arise in our environment and then describes the core of the solution to the problem, in which we can reuse the existing solutions countless times without having to repeat the same work.
A pattern is a solution to a problem in a context
Patterns are a scenario for solving problems in a specific environment

    • Software mode


Gang of Four
In 1990, the software engineering community began to pay attention to the major breakthroughs in the field of residential, public and urban planning, such as Christopher Alexander, which was first introduced into software engineering methodology in 1991-1992 with the " Four-person group (Gang of Four, GoF, a four-famous software engineering scholar called Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides , concluded in 1994 that 23 of the more frequently used design patterns in software development were released , which aims to use patterns to unify the gap between the analysis, design and implementation of object-oriented approaches.

The software pattern is to apply the general concept of the pattern to the field of software development, that is, the general guiding idea or reference model of software development. Software patterns are not limited to design patterns, but also include architectural patterns, analysis patterns, and process patterns, and in fact, there are a number of agreed patterns at each stage of the software's lifetime.
The software pattern can be regarded as a kind of unified representation of the "solution" of the specific "problem" of software development, which is exactly the same as the pattern definition described by Alexander, that is, the software pattern is equal to the appearing problem and solution under certain conditions. The infrastructure of the software pattern consists of 4 parts: The problem description, the precondition (environment or constraint), the solution and the effect .

The software pattern is independent of the specific application domain, and in the pattern discovery process it is necessary to follow the rule of three, which means that only three or more different types (or different domains) of the system are validated , a solution can be upgraded from candidate mode to pattern.

    • Development of design Patterns


    • Definition and classification of design patterns

Definition of design pattern
Design patterns are a set of reusable, most known, categorized purposes, code design experiences that use design patterns to reuse code, make code easier for others to understand, and ensure code reliability.

Basic elements of design patterns

Design patterns generally have the following basic elements: schema name, problem, purpose, solution, effect, instance code, and related design patterns, the key elements of which include the following four aspects:
Pattern names (pattern name)
Question (problem)
Solutions (solution)
Effect (Consequences)

Design Pattern Learning Steps
Pattern motivation and Definition
Pattern Structure and analysis
Pattern Instances and parsing
Pattern Effects and applications
Pattern extension

Classification of design Patterns
according to its purpose (what the pattern is used for) can be divided into the creation type (creational), the structure type (Structural) and the Behavior type (behavioral) three kinds :
The create pattern is primarily used to create objects.
A structured pattern is primarily used to handle a combination of classes or objects.
Behavioral patterns are primarily used to describe how classes or objects interact and assign responsibilities.
Depending on the scope, whether the pattern is primarily used to deal with relationships between classes or between objects, there are two types of class patterns and object patterns:
The class pattern handles the relationship between classes and subclasses, which are established by inheritance and are determined at compile time and are static.
Object patterns deal with the relationships between objects, which change at run time and are more dynamic.

    • Introduction to GOF Design Patterns

Scope \ Purpose

Create-mode

strong> Structural mode

Behavioral mode

class mode

Factory method mode

(class) adapter mode

Interpreter Mode

Template method mode

Object mode

Abstract Factory mode

Builder mode

Prototype mode

Singleton mode

(object) adapter mode

Bridging mode

Combo mode

Decorative mode

Appearance mode

Enjoy meta mode

Proxy mode

Responsibility chain mode

Command mode

Iterator mode

Broker mode

Memo mode

Watcher mode

State mode

Policy mode

Visitor mode

    • Advantages of design mode

The

Design pattern is a successful, maintainable reuse design that has been summed up from many good software systems, and the use of these schemes will prevent us from doing repetitive work and can design high-quality software systems. The main advantages of the
design pattern are as follows:
? Design Patterns fused The experience of many experts , and in a for the vast majority of developers, it provides to facilitate communication and communication between developers, Make the design scheme more easy to understand. For developers and designers who use different programming languages, design patterns can be used to communicate system design, and each model corresponds to a standard solution, .
? Design patterns enable people to , The presentation of proven technologies into design patterns will also make it easier for new system developers to understand their design ideas. Design patterns make it easier to reuse successful designs and avoid design scenarios that lead to non-reusable designs.
? Design pattern makes the design more flexible and easy to modify .
? The use of design patterns will .
? Design Patterns Help beginners have a deeper understanding of object-oriented thinking , which helps beginners to read and learn the source code of existing class libraries and other systems more easily , on the other hand, it can improve the level of software design and code quality.

    • Create Pattern Overview

The creation pattern (creational pattern) abstracts the instantiation of a class, allowing the creation of objects in the software module to be separated from the use of objects. In order to make the structure of the software more clear, the outside world only need to know their common interface, but not the specific implementation details, so that the whole system design more in line with the principle of single responsibility.

The creation model provides the greatest flexibility for software designers in terms of what to create, who to create (WHO), and when to create (when). The Create pattern hides the creation details of instances of classes, by hiding how objects are created and grouped together to achieve the purpose of making the whole system independent.

Introduction to creating Patterns
Simple Factory mode (Factory)
Factory mode (Factory method)
Abstract Factory mode (Factory)
Builder Mode (creator)
Prototype mode (PROTOTYPE)
Singleton mode (Singleton)

    • Overview of structural patterns

The structural pattern (Structural pattern) describes how to combine classes or objects together to form larger structures, like building blocks that can form complex, more powerful structures through the combination of simple bricks.

Structured patterns can be categorized into class-structured patterns and object-structured patterns:
The class-structured pattern is a combination of classes that can be combined into a larger system, in which there is generally only inheritance and implementation relationships in class-structured patterns.
? The object structure pattern concerns the combination of a class and an object, through which an instance object of another class is defined in one class, and then its methods are called through the object. According to the principle of "synthetic reuse", most of the structural patterns are object-structured patterns, as far as possible the use of association relationships in the system to replace the inheritance relationship.

Introduction to structural patterns
? adapter mode (Adapter)
? Bridging mode (bridge)
? combination mode (Composite)
? decoration Mode (Decorator)
? appearance mode (facade)
? Enjoy meta mode (Flyweight)
Agent mode (proxy)

    • An overview of behavioral patterns

Behavioral patterns (behavioral pattern) are the abstraction of dividing responsibilities and algorithms between different objects.
Behavioral patterns focus not only on the structure of classes and objects, but also on their interactions.
With behavioral patterns, you can more clearly divide the responsibilities of classes and objects, and study the interaction of the system between instance objects at run time. When the system is running, objects are not orphaned, they can accomplish some complex functions by communicating and collaborating with each other, and one object at run time will also affect the operation of other objects.

Behavioral patterns are divided into class-behavioral patterns and object-behavioral patterns in two ways:
The class behavior pattern: The behavior pattern of a class uses an inheritance relationship to distribute behavior among several classes, and the class behavior pattern allocates the responsibilities of the parent class and the subclass primarily through polymorphism.
The object behavior pattern: The object's behavioral pattern uses the object's aggregate affinity to assign the behavior, and the object's behavioral pattern is to assign the responsibilities of two or more classes by means of object affinity. According to the principle of "synthetic reuse", in order to use association relation to replace the inheritance relation, most behavioral design patterns belong to the object behavior design pattern.

Introduction to Behavioral patterns
? Responsibility chain mode (Chain of Responsibility)
? Command mode
? Interpreter mode (interpreter)
? iterator mode (Iterator)
? Broker Mode (mediator)
Memo Mode (Memento)
? Observer mode (OBSERVER)
? status mode (state)
? Policy mode (strategy)
? Template Method Mode
? Visitor Mode (Visitor)

Overview of the "OOAD" design pattern

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.