Skip to content

Commit 905a4a0

Browse files
committed
edit readme
edit readme
1 parent 8b0672b commit 905a4a0

File tree

9 files changed

+50
-50
lines changed

9 files changed

+50
-50
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
# Chain of Responsibility Pattern 责任链模式
2-
##Definition
2+
## Definition
33

44
Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it.
55
<br>使多个对象都有机会处理请求,从而避免了请求的发送者和接受者之间的耦合关系。将这些对象连成一条链,并沿着这条链传递该请求,直到有对象处理它为止。
66

77
![](https://github.com/QianMo/Unity-Design-Pattern/blob/master/UML_Picture/chain.gif)
88

99

10-
##Participants
10+
## Participants
1111

1212
The classes and objects participating in this pattern are:
1313

14-
###Handler (Approver)
14+
### Handler (Approver)
1515
* defines an interface for handling the requests
1616
* (optional) implements the successor link
1717

18-
###ConcreteHandler (Director, VicePresident, President)
18+
### ConcreteHandler (Director, VicePresident, President)
1919
* handles requests it is responsible for
2020
* can access its successor
2121
* if the ConcreteHandler can handle the request, it does so; otherwise it forwards the request to its successor
2222

23-
###Client (ChainApp)
23+
### Client (ChainApp)
2424
* initiates the request to a ConcreteHandler object on the chain
2525

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
# Interpreter Pattern 解释器模式
2-
##Definition
2+
## Definition
33

44
Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language.
55
<br>给定一门语言,定义它的文法的一种表示,并定义一个解释器,该解释器使用该表示来解释语言中的句子。
66

77
![](https://github.com/QianMo/Unity-Design-Pattern/blob/master/UML_Picture/interpreter.gif)
88

99

10-
##Participants
10+
## Participants
1111

1212
The classes and objects participating in this pattern are:
1313

14-
###AbstractExpression (Expression)
14+
### AbstractExpression (Expression)
1515
* declares an interface for executing an operation
1616

17-
###TerminalExpression ( ThousandExpression, HundredExpression, TenExpression, OneExpression )
17+
### TerminalExpression ( ThousandExpression, HundredExpression, TenExpression, OneExpression )
1818
* implements an Interpret operation associated with terminal symbols in the grammar.
1919
* an instance is required for every terminal symbol in the sentence.
2020

21-
###NonterminalExpression ( not used )
21+
### NonterminalExpression ( not used )
2222
* one such class is required for every rule R ::= R1R2...Rn in the grammar
2323
* maintains instance variables of type AbstractExpression for each of the symbols R1 through Rn.
2424
* implements an Interpret operation for nonterminal symbols in the grammar. Interpret typically calls itself recursively on the variables representing R1 through Rn.
2525

26-
###Context (Context)
26+
### Context (Context)
2727
* contains information that is global to the interpreter
2828

29-
###Client (InterpreterApp)
29+
### Client (InterpreterApp)
3030
* builds (or is given) an abstract syntax tree representing a particular sentence in the language that the grammar defines. The abstract syntax tree is assembled from instances of the NonterminalExpression and TerminalExpression classes
3131
* invokes the Interpret operation
3232

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
# Iterator Pattern 迭代器模式
2-
##Definition
2+
## Definition
33

44
Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.
55
<br>提供一种方法访问一个容器对象中各个元素,而又不需暴露该对象的内部细节。
66

77
![](https://github.com/QianMo/Unity-Design-Pattern/blob/master/UML_Picture/iterator.gif)
88

99

10-
##Participants
10+
## Participants
1111

1212
The classes and objects participating in this pattern are:
1313

14-
###Iterator (AbstractIterator)
14+
### Iterator (AbstractIterator)
1515
* defines an interface for accessing and traversing elements.
1616

17-
###ConcreteIterator (Iterator)
17+
### ConcreteIterator (Iterator)
1818
* implements the Iterator interface.
1919
* keeps track of the current position in the traversal of the aggregate.
2020

21-
###Aggregate (AbstractCollection)
21+
### Aggregate (AbstractCollection)
2222
* defines an interface for creating an Iterator object
2323

24-
###ConcreteAggregate (Collection)
24+
### ConcreteAggregate (Collection)
2525
* implements the Iterator creation interface to return an instance of the proper ConcreteIterator
2626

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
# Mediator Pattern 中介者模式
2-
##Definition
2+
## Definition
33

44
Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently.
55
<br>用一个中介对象封装一系列的对象交互,中介者使各对象不需要显示地相互作用,从而使其耦合松散,而且可以独立地改变它们之间的交互。
66

77
![](https://github.com/QianMo/Unity-Design-Pattern/blob/master/UML_Picture/mediator.gif)
88

99

10-
##Participants
10+
## Participants
1111

1212
The classes and objects participating in this pattern are:
1313

14-
###Mediator (IChatroom)
14+
### Mediator (IChatroom)
1515
* defines an interface for communicating with Colleague objects
1616

17-
###ConcreteMediator (Chatroom)
17+
### ConcreteMediator (Chatroom)
1818
* implements cooperative behavior by coordinating Colleague objects
1919
* knows and maintains its colleagues
2020

21-
###Colleague classes (Participant)
21+
### Colleague classes (Participant)
2222
* each Colleague class knows its Mediator object
2323
* each colleague communicates with its mediator whenever it would have otherwise communicated with another colleague
2424

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
# Memento Pattern 备忘录模式
2-
##Definition
2+
## Definition
33

44
Without violating encapsulation, capture and externalize an object's internal state so that the object can be restored to this state later.
55
<br>在不破坏封装性的前提下,捕获一个对象的内部状态,并在该对象之外保存这个状态。这样以后就可将该对象恢复到原先保存的状态。
66

77
![](https://github.com/QianMo/Unity-Design-Pattern/blob/master/UML_Picture/memento.gif)
88

99

10-
##Participants
10+
## Participants
1111

1212
The classes and objects participating in this pattern are:
1313

14-
###Memento (Memento)
14+
### Memento (Memento)
1515
* stores internal state of the Originator object. The memento may store as much or as little of the originator's internal state as necessary at its originator's discretion.
1616
* protect against access by objects of other than the originator. Mementos have effectively two interfaces. Caretaker sees a narrow interface to the Memento -- it can only pass the memento to the other objects. Originator, in contrast, sees a wide interface, one that lets it access all the data necessary to restore itself to its previous state. Ideally, only the originator that produces the memento would be permitted to access the memento's internal state.
1717

18-
###Originator (SalesProspect)
18+
### Originator (SalesProspect)
1919
* creates a memento containing a snapshot of its current internal state.
2020
* uses the memento to restore its internal state
2121

22-
###Caretaker (Caretaker)
22+
### Caretaker (Caretaker)
2323
* is responsible for the memento's safekeeping
2424
* never operates on or examines the contents of a memento.
2525

Assets/Behavioral Patterns/Observer Pattern/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
# Observer Pattern 观察者模式
2-
##Definition
2+
## Definition
33

44
Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
55
<br>定义对象间一种一对多的依赖关系,使得每当一个对象改变状态,则所有依赖于它的对象都会得到通知并被自动更新。
66

77
![](https://github.com/QianMo/Unity-Design-Pattern/blob/master/UML_Picture/observer.gif)
88

99

10-
##Participants
10+
## Participants
1111

1212
The classes and objects participating in this pattern are:
1313

14-
###Subject (Stock)
14+
### Subject (Stock)
1515
* knows its observers. Any number of Observer objects may observe a subject
1616
* provides an interface for attaching and detaching Observer objects.
1717

18-
###ConcreteSubject (IBM)
18+
### ConcreteSubject (IBM)
1919
* stores state of interest to ConcreteObserver
2020
* sends a notification to its observers when its state changes
2121

22-
###Observer (IInvestor)
22+
### Observer (IInvestor)
2323
* defines an updating interface for objects that should be notified of changes in a subject.
2424

25-
###ConcreteObserver (Investor)
25+
### ConcreteObserver (Investor)
2626
* maintains a reference to a ConcreteSubject object
2727
* stores state that should stay consistent with the subject's
2828
* implements the Observer updating interface to keep its state consistent with the subject's

Assets/Behavioral Patterns/Strategy Pattern/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
# Strategy Pattern 策略模式
2-
##Definition
2+
## Definition
33

44
Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
55
<br>定义一组算法,将每个算法都封装起来,并且使它们之间可以互换
66

77
![](https://github.com/QianMo/Unity-Design-Pattern/blob/master/UML_Picture/strategy.gif)
88

99

10-
##Participants
10+
## Participants
1111

1212
The classes and objects participating in this pattern are:
1313

14-
###Strategy (SortStrategy)
14+
### Strategy (SortStrategy)
1515
* declares an interface common to all supported algorithms. Context uses this interface to call the algorithm defined by a ConcreteStrategy
1616

17-
###ConcreteStrategy (QuickSort, ShellSort, MergeSort)
17+
### ConcreteStrategy (QuickSort, ShellSort, MergeSort)
1818
* implements the algorithm using the Strategy interface
1919

20-
###Context (SortedList)
20+
### Context (SortedList)
2121
* is configured with a ConcreteStrategy object
2222
* maintains a reference to a Strategy object
2323
* may define an interface that lets Strategy access its data.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
# Template Method Pattern 模板方法模式
2-
##Definition
2+
## Definition
33

44
Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure.
55
<br>定义一个操作中的算法的框架,而将一些步骤延迟到子类中。使得子类可以不改变一个算法的结构即可重定义该算法的某些特定步骤。
66

77
![](https://github.com/QianMo/Unity-Design-Pattern/blob/master/UML_Picture/template.gif)
88

99

10-
##Participants
10+
## Participants
1111

1212
The classes and objects participating in this pattern are:
1313

14-
###AbstractClass (DataObject)
14+
### AbstractClass (DataObject)
1515
* defines abstract primitive operations that concrete subclasses define to implement steps of an algorithm
1616
* implements a template method defining the skeleton of an algorithm. The template method calls primitive operations as well as operations defined in AbstractClass or those of other objects.
1717

18-
###ConcreteClass (CustomerDataObject)
18+
### ConcreteClass (CustomerDataObject)
1919
* implements the primitive operations ot carry out subclass-specific steps of the algorithm
2020

Assets/Behavioral Patterns/Visitor Pattern/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
# Visitor Pattern 访问者模式
2-
##Definition
2+
## Definition
33

44
Represent an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it operates.
55
<br>封装一些作用于某种数据结构中的各元素的操作,它可以在不改变数据结构的前提下定义作用于这些元素的新的操作。
66

77
![](https://github.com/QianMo/Unity-Design-Pattern/blob/master/UML_Picture/visitor.gif)
88

99

10-
##Participants
10+
## Participants
1111

1212
The classes and objects participating in this pattern are:
1313

14-
###Visitor (Visitor)
14+
### Visitor (Visitor)
1515
* declares a Visit operation for each class of ConcreteElement in the object structure. The operation's name and signature identifies the class that sends the Visit request to the visitor. That lets the visitor determine the concrete class of the element being visited. Then the visitor can access the elements directly through its particular interface
1616

17-
###ConcreteVisitor (IncomeVisitor, VacationVisitor)
17+
### ConcreteVisitor (IncomeVisitor, VacationVisitor)
1818
* implements each operation declared by Visitor. Each operation implements a fragment of the algorithm defined for the corresponding class or object in the structure. ConcreteVisitor provides the context for the algorithm and stores its local state. This state often accumulates results during the traversal of the structure.
1919

20-
###Element (Element)
20+
### Element (Element)
2121
* defines an Accept operation that takes a visitor as an argument.
2222

23-
###ConcreteElement (Employee)
23+
### ConcreteElement (Employee)
2424
* implements an Accept operation that takes a visitor as an argument
2525

26-
###ObjectStructure (Employees)
26+
### ObjectStructure (Employees)
2727
* can enumerate its elements
2828
* may provide a high-level interface to allow the visitor to visit its elements
2929
* may either be a Composite (pattern) or a collection such as a list or a set

0 commit comments

Comments
 (0)