9th: Common Design Patterns 9.1 aggregation componentsConsider providing aggregation components for commonly used attribute domains.The aggregation component is used to model the concept of a high-level (physical object), rather than to model the system-level tasks.To make the name of the aggregation component correspond to well-known system entities, such as MessageQueue, Process, or EventLog, you can make
Architectural Design Source: Scenario Analysis of design patterns (1) publish-subscribe
Author: poechant
Blog: blog.csdn.net/poechant
Email: zhongchao.ustc@gmail.com
Date: February 24Th, 2012
I have read only the original English (or photocopy) books and some documents on the Internet in terms of design
: This article mainly introduces the delegated design mode of common PHP design patterns. For more information about PHP tutorials, see. Mode definition
Delegation is a method to extend and reuse the functions of a class. The method is to write an additional class to provide additional functions, and use the original class instance to provide the original funct
If the classes are tightly coupled, it is difficult to reuse them separately because they depend on each other. Therefore, a single block system is generated. You cannot modify or remove a single class unless you understand the internal relationship or involve many classes. Dense mass of the entire system are hard to learn, transplant, and maintain.
Loose coupling enhances the possibility of reusing a single class and the entire system is easy to understand, transplant, modify
Design patterns are specific solution patterns (routines) that can be reused for specific problems in a specific situation that is constantly emerging. According to the three categories of creation, structure and behavior, this paper summarizes the main points of use of 24 kinds of design
1. four essential elements of a pattern:(1) pattern name;(2) problem;(3) solution;(4) consequences: the results and trade-offs of applying the pattern.
2. One person's pattern can be another person's primitive building block.
3. The design patterns in this book are descriptions of communicating objects and classes that are customized to solve a general design p
behavior that may change and make it open. It contains three meanings: first, the interface and abstract class are used to limit the boundaries of the extension. Public methods that do not exist in the interface or abstract class are not allowed; second, the parameter type and referenced object should try to use interfaces or abstract classes instead of implementation classes. Third, the abstraction layer remains stable and cannot be modified once determined.
2) metadata (metadata) controls
Classification of plant design and design patterns: The factory model is divided into three categories in Java and mode:1) Simple Factory mode (simply Factory): not conducive to the production of products;2) Factory method mode (Factory): Also known as the polymorphism plant;3) Abstract Factory mode (abstract Factory): Also known as the toolbox, producing product
diagram for FilterInputStream:As can be seen, InputStream class is an abstract component exists, and FileInputStream is a specific component, it implements the abstract components of all interfaces, FilterInputStream class is the decorative role, It implements all interfaces of the InputStream class and holds a reference to the InputStream object instance, Bufferedinputstream is the specific adorner implementation, the role of this adorner class is to make the InputStream read data stored in me
Design patterns are not completely independent, but each other, there will be some of the same shadow, let's summarize the 24 design patterns together.
Pattern Classification Portal Contrast Dimension description design principles: des
objects; The new object is used to re-use its existing functions by delegating methods that call existing objects. In short: Use the combination/aggregation relationship as much as possible, with less inheritance.7, Dimitri Law (least known principle) (Demeter Principle)Why is it called the least known principle, that is to say: an entity should be as small as possible interaction with other entities, so that the system function module is relatively independent. This means that a software entit
Six main principles:Single duty;Opening and closing principle;Dimitri Principle;The principle of the Richter replacement;dependency inversion principle;Interface Isolation principle23 Different design modes:Create Five types of models: Factory method mode, abstract Factory mode, singleton mode, builder mode, prototype mode. structure mode , a total of seven kinds: Adapter mode, adorner mode, proxy mode, appearance mode, bridging mode, combined mode, e
copy behavior of the object, you should also override the Copywithzone: methodOverrides should ensure that no new objects are created, such as:-(ID) Copywithzone: (struct _nszone *) zone {return self}5) If memory management uses non-arc, also consider overriding the Retain methodIt is necessary to ensure that the single object release is destroyed once, and retain does not make any sense, such as:-(ID) retain{return self;}
Implementation of single-instance
(' Myctrl ', function () {});④ using the Controller:Ngcontroller directive: ng-controller= "Myctrl";⑤ in the controller's callback function, the $scope object is injected, specifying the model data: $scope. variable = value;⑥ Display:{{}}--ng directive:$scope scope control objects to connect model data to views;Initialize Data--nginit:$scope object;⑦ directive:Ng-click, Ng-dbclick, Ng-focus, Ng-blur;⑧ Note:Define model data, must inject $scope;In order to identify the variables and methods decl
The side dishes of the IT workplace often have these questions:
Why a similar function, Daniel will be done in a moment, and then leisurely tasting afternoon tea shopping Taobao, and their own overtime to get to the dawn can not finish.
Why the user proposed changes in demand, Daniel just smart to knock on the keyboard, change the configuration, and their own code changed and changed, deleted and built, almost fainted, the last can only overturn.
Why Daniel finished the program test on the line,
Introduction to Design Patterns
Each pattern describes a problem that recurs around us, and the core of the solution to the problem.--Christopher Alexander
The design pattern describes a general solution to some common problems in the software design process. The object-oriented
language is:1 , the dependencies between the modules can occur through abstraction, and the implementation class cannot have direct dependencies between them, and their dependencies are generated by interfaces or abstract classes;2 , interface, or abstract class does not depend on the implementation class;3 , implementing class-dependent interfaces or abstract classes;a more streamlined definition is "interface-oriented programming" ------OOD one of the essence. Benefits of the dependency inver
classes have the same behavior and state.4), ISP (Interface segregation Principle): interface separation principle;Client should not being forced to using a interface if it does not need it. Interface separation rules are designed to work with multiple specific functionsInterface to avoid the redundancy caused by the common interface.5), DIP (Dependency inversion Principle): dependency inversion principle;The high level modules should is depend on the low level modules but the should depend on
"/"; return NewChu ($a,$b); Break; Case"%"; return NewQuyu ($a,$b); Break; } } } $j= Gongchang::d uixiang (3,2, "%");//Test Echo $j->js ();//OutputOutput resultsSecond, the design of six major principles1. The open-close principle is that the design should have good support for the extension, and the modification should be strictly limited.2. On the Richter scale also, the subclass mu
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.