Presentation is loading. Please wait.

Presentation is loading. Please wait.

Composite and Related Patterns Kirk Scott. The pitohui, a poisonous bird of New Guinea.

Similar presentations


Presentation on theme: "Composite and Related Patterns Kirk Scott. The pitohui, a poisonous bird of New Guinea."— Presentation transcript:

1 Composite and Related Patterns Kirk Scott

2 The pitohui, a poisonous bird of New Guinea

3 This is an introductory unit. These are the units/chapters belonging to this section of the course: Unit 25, Composite, book chapter 5 Unit 26, Chain of Responsibility, book chapter 12 Unit 27, Interpreter, book chapter 25 Unit 28, Visitor, book chapter 29

4 What will be given next is an extremely brief overview of these topics. You will find that the composite design pattern has a lot in common with trees Chain of responsibility, interpreter, and visitor all follow naturally, because interesting examples of those patterns can be built on top of composites/trees

5 Composite Book definition: The intent of the Composite pattern is to let clients treat individual objects and compositions of objects uniformly Comment mode on: A composite can consist of one or more components Each component may be a single item or another composite

6 In the verbal description above you may recognize the elements of a definition of a tree-like structure It is reminiscent of directory structures which can contain individual files as well as other directories This pattern has a distinctive UML diagram. See the next overhead

7

8 Chain of Responsibility Book definition: The intent of the Chain of Responsibility pattern is to avoid coupling the sender of a request to its receiver, by giving more than one object a chance to handle the request. Comment mode on: If a set of objects is linked together, you may call a method on one. Potentially that one calls a method on the next in the chain, and so on down the line

9 Interpreter Book definition: The intent of the Interpreter pattern is to let you compose executable objects according to a set of composition rules that you define. Comment mode on: This directly parallels composite Interpreters interpret commands Commands can consist of single commands or collections (composites) of commands

10 Visitor Book definition: The intent of Visitor is to let you define a new operation for a hierarchy without changing the hierarchy classes. Comment mode on: The relationship with composite is that the hierarchy you define the operation for may be the component/leaf/composite hierarchy which generates a tree

11 In Summary and Mnemonic Devices: Composite: = Tree Chain of Responsibility: Think “Tree of Responsibility” Interpreter: Remember the analogy between directory structures and program structures (routines and subroutines) Visitor: Visiting the branches and leaves of trees…

12 The End


Download ppt "Composite and Related Patterns Kirk Scott. The pitohui, a poisonous bird of New Guinea."

Similar presentations


Ads by Google