Pattern Oriented Design Chain of Responsibility From:Design Patterns Gamma. Johnson Helm. Vlissides...
-
Upload
marian-flowers -
Category
Documents
-
view
232 -
download
14
Transcript of Pattern Oriented Design Chain of Responsibility From:Design Patterns Gamma. Johnson Helm. Vlissides...
![Page 1: Pattern Oriented Design Chain of Responsibility From:Design Patterns Gamma. Johnson Helm. Vlissides (GoF) Present: F8906082 楊汝康 R9306008 徐德皓 R9306016 高稚翔.](https://reader036.fdocuments.in/reader036/viewer/2022062314/56649efe5503460f94c1336e/html5/thumbnails/1.jpg)
Pattern Oriented Design Chain of Responsibility
From: Design Patterns Gamma. Johnson Helm. Vlissides (GoF)Present: F8906082 楊汝康 R9306008 徐德皓 R9306016 高稚翔
R9306024 陳錫樺 R9306025 葉冠良 R9306029 謝漢風 2004/Dec/21
![Page 2: Pattern Oriented Design Chain of Responsibility From:Design Patterns Gamma. Johnson Helm. Vlissides (GoF) Present: F8906082 楊汝康 R9306008 徐德皓 R9306016 高稚翔.](https://reader036.fdocuments.in/reader036/viewer/2022062314/56649efe5503460f94c1336e/html5/thumbnails/2.jpg)
2004/Dec/21 2
Outline
Introduction 高稚翔 Structure Example 高稚翔 Object Example 葉冠良 Object Diagram 葉冠良 Non-software 葉冠良 UI Operation Example 陳錫樺 Interaction Diagram 陳錫樺 Successor 謝漢風 Class Diagram 謝漢風 Structure 徐德皓 Collaborations 徐德皓 Consequences of Behavior Patterns 楊汝康
![Page 3: Pattern Oriented Design Chain of Responsibility From:Design Patterns Gamma. Johnson Helm. Vlissides (GoF) Present: F8906082 楊汝康 R9306008 徐德皓 R9306016 高稚翔.](https://reader036.fdocuments.in/reader036/viewer/2022062314/56649efe5503460f94c1336e/html5/thumbnails/3.jpg)
2004/Dec/21 3
Introduction
3 majors 1.Creational Patterns
Abstract factory 、 builder…. Etc. 2.Structural Patterns
adapter 、 facade 、 proxy…etc. 3.Behavioral Patterns
Chain of responsibility 、 command 、 memento…etc.
![Page 4: Pattern Oriented Design Chain of Responsibility From:Design Patterns Gamma. Johnson Helm. Vlissides (GoF) Present: F8906082 楊汝康 R9306008 徐德皓 R9306016 高稚翔.](https://reader036.fdocuments.in/reader036/viewer/2022062314/56649efe5503460f94c1336e/html5/thumbnails/4.jpg)
2004/Dec/21 4
Introduction
Chain of Responsibility 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.
![Page 5: Pattern Oriented Design Chain of Responsibility From:Design Patterns Gamma. Johnson Helm. Vlissides (GoF) Present: F8906082 楊汝康 R9306008 徐德皓 R9306016 高稚翔.](https://reader036.fdocuments.in/reader036/viewer/2022062314/56649efe5503460f94c1336e/html5/thumbnails/5.jpg)
2004/Dec/21 5
Structure Example
if(/* 符合請求條件一 */)// 執行請求一else if(/* 符合請求條件二 */)// 執行請求二else// 執行預設請求或顯示訊息
![Page 6: Pattern Oriented Design Chain of Responsibility From:Design Patterns Gamma. Johnson Helm. Vlissides (GoF) Present: F8906082 楊汝康 R9306008 徐德皓 R9306016 高稚翔.](https://reader036.fdocuments.in/reader036/viewer/2022062314/56649efe5503460f94c1336e/html5/thumbnails/6.jpg)
2004/Dec/21 6
Object Example
Consider a context-sensitive help facility for a graphical user interface. The user can obtain help information on any part of the interface just by clicking on it(F1)
![Page 7: Pattern Oriented Design Chain of Responsibility From:Design Patterns Gamma. Johnson Helm. Vlissides (GoF) Present: F8906082 楊汝康 R9306008 徐德皓 R9306016 高稚翔.](https://reader036.fdocuments.in/reader036/viewer/2022062314/56649efe5503460f94c1336e/html5/thumbnails/7.jpg)
2004/Dec/21 7
Object Diagram
The goal is avoid the coupling
![Page 8: Pattern Oriented Design Chain of Responsibility From:Design Patterns Gamma. Johnson Helm. Vlissides (GoF) Present: F8906082 楊汝康 R9306008 徐德皓 R9306016 高稚翔.](https://reader036.fdocuments.in/reader036/viewer/2022062314/56649efe5503460f94c1336e/html5/thumbnails/8.jpg)
2004/Dec/21 8
Non-software
Domian
Domian
DomainDomainDomian
Domian
DomainDomain
DomainDomain
Host A
![Page 9: Pattern Oriented Design Chain of Responsibility From:Design Patterns Gamma. Johnson Helm. Vlissides (GoF) Present: F8906082 楊汝康 R9306008 徐德皓 R9306016 高稚翔.](https://reader036.fdocuments.in/reader036/viewer/2022062314/56649efe5503460f94c1336e/html5/thumbnails/9.jpg)
2004/Dec/21 9
Interaction Diagram
Neither aPrintButtom nor aPrintDialog handles the request; it stops at anApplication, which can handle it or ignore it.
![Page 10: Pattern Oriented Design Chain of Responsibility From:Design Patterns Gamma. Johnson Helm. Vlissides (GoF) Present: F8906082 楊汝康 R9306008 徐德皓 R9306016 高稚翔.](https://reader036.fdocuments.in/reader036/viewer/2022062314/56649efe5503460f94c1336e/html5/thumbnails/10.jpg)
2004/Dec/21 10
UI Operation Example
![Page 11: Pattern Oriented Design Chain of Responsibility From:Design Patterns Gamma. Johnson Helm. Vlissides (GoF) Present: F8906082 楊汝康 R9306008 徐德皓 R9306016 高稚翔.](https://reader036.fdocuments.in/reader036/viewer/2022062314/56649efe5503460f94c1336e/html5/thumbnails/11.jpg)
2004/Dec/21 11
UI Operation Example
![Page 12: Pattern Oriented Design Chain of Responsibility From:Design Patterns Gamma. Johnson Helm. Vlissides (GoF) Present: F8906082 楊汝康 R9306008 徐德皓 R9306016 高稚翔.](https://reader036.fdocuments.in/reader036/viewer/2022062314/56649efe5503460f94c1336e/html5/thumbnails/12.jpg)
2004/Dec/21 12
Successor
To forward the request along the chain, and to ensure receivers remain implicit, each object on the chain shares a common interface for handling requests and for accessing its successor on the chain
1 2 3
![Page 13: Pattern Oriented Design Chain of Responsibility From:Design Patterns Gamma. Johnson Helm. Vlissides (GoF) Present: F8906082 楊汝康 R9306008 徐德皓 R9306016 高稚翔.](https://reader036.fdocuments.in/reader036/viewer/2022062314/56649efe5503460f94c1336e/html5/thumbnails/13.jpg)
2004/Dec/21 13
Class DiagramSuper class
![Page 14: Pattern Oriented Design Chain of Responsibility From:Design Patterns Gamma. Johnson Helm. Vlissides (GoF) Present: F8906082 楊汝康 R9306008 徐德皓 R9306016 高稚翔.](https://reader036.fdocuments.in/reader036/viewer/2022062314/56649efe5503460f94c1336e/html5/thumbnails/14.jpg)
2004/Dec/21 14
Structure
Handler HelpHandler
ConcreteHandler PrintButtom, PrintDailog
Client
![Page 15: Pattern Oriented Design Chain of Responsibility From:Design Patterns Gamma. Johnson Helm. Vlissides (GoF) Present: F8906082 楊汝康 R9306008 徐德皓 R9306016 高稚翔.](https://reader036.fdocuments.in/reader036/viewer/2022062314/56649efe5503460f94c1336e/html5/thumbnails/15.jpg)
2004/Dec/21 15
Collaborations
When a client issues a request, the request propagates along the chain until a ConcreteHandler object takes responsibility for handling it.
![Page 16: Pattern Oriented Design Chain of Responsibility From:Design Patterns Gamma. Johnson Helm. Vlissides (GoF) Present: F8906082 楊汝康 R9306008 徐德皓 R9306016 高稚翔.](https://reader036.fdocuments.in/reader036/viewer/2022062314/56649efe5503460f94c1336e/html5/thumbnails/16.jpg)
2004/Dec/21 16
Consequences
Has the following benefits and liabilities Advantage
Reduced coupling. Added flexibility in assigning responsibility to objects
disadvantage Receipt isn’t guaranteed
![Page 17: Pattern Oriented Design Chain of Responsibility From:Design Patterns Gamma. Johnson Helm. Vlissides (GoF) Present: F8906082 楊汝康 R9306008 徐德皓 R9306016 高稚翔.](https://reader036.fdocuments.in/reader036/viewer/2022062314/56649efe5503460f94c1336e/html5/thumbnails/17.jpg)
2004/Dec/21 17
Consequences of Behavior Patterns Separate the sender receiver
Command Observer Mediator Chain of Responsibility
![Page 18: Pattern Oriented Design Chain of Responsibility From:Design Patterns Gamma. Johnson Helm. Vlissides (GoF) Present: F8906082 楊汝康 R9306008 徐德皓 R9306016 高稚翔.](https://reader036.fdocuments.in/reader036/viewer/2022062314/56649efe5503460f94c1336e/html5/thumbnails/18.jpg)
2004/Dec/21 18
End
Any questions?