0
Chain-Of-Responsibility    Design Pattern
OverviewObjectiveLearn how to use the Chain Of Responsibility designpattern.Requirements Basics of Protected Methods Bas...
Follow Along With Code           Example1. Download a copy of the example code at  www.prodigyview.com/source.2. Install t...
What is the Chain –Of-          Responsibility?The Chain-of-responsibility is a design pattern that hascommand objects and...
Chain-of-Responsibility VisualCall Method lookUp()                            Method turnLeft();                          ...
Command in ProdigyView     The Chain-of-responsibility is implemented in     ProdigyView by extending the PVApplication or...
Command InterpreterSo genius, you have a class that is full of protected methodsand no way to access them, how are we goin...
Command Interpreter ExampleThe method that will be called                  The arguements passed to the method
Command Interpreter ResultsThe results from passing those commands should looklike this.
The Not So Obvious1. PVApplication extends PVObject which extends   PVPatterns. This means any object that extends   PVApp...
Challenge!This is an optional challenge designed to help you betterunderstand the design pattern.Create two classes that b...
Summary1. Have an object extend PVApplication2. Create methods inside that object. They can be   protected or public if th...
API ReferenceFor a better understanding of the Collections and theIterator, check out the api at the two links below.PVApp...
Upcoming SlideShare
Loading in...5
×

Learn the Chain of Responsibility Design Pattern

3,447

Published on

Learn how to implement chain of responsibility design pattern

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
3,447
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
22
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Learn the Chain of Responsibility Design Pattern"

  1. 1. Chain-Of-Responsibility Design Pattern
  2. 2. OverviewObjectiveLearn how to use the Chain Of Responsibility designpattern.Requirements Basics of Protected Methods Basics of Abstract ClassesEstimated Time6 minutes www.prodigyview.com
  3. 3. Follow Along With Code Example1. Download a copy of the example code at www.prodigyview.com/source.2. Install the system in an environment you feel comfortable testing in.3. Proceed to examples/data/Command.php
  4. 4. What is the Chain –Of- Responsibility?The Chain-of-responsibility is a design pattern that hascommand objects and processing objects. The commandobjects iterates through the processing objects and executeson the processing objects that can handle the request.Translated into English, a method in on object is called and itsearches for other objects that can handle the methodsrequest.In ProdigyView,, the chain-of-responsibility is a little different.An object methods are ran through until the correct method isfound and then that method is executed.
  5. 5. Chain-of-Responsibility VisualCall Method lookUp() Method turnLeft(); Method turnRight(); Output Method lookUp(); Method lookDown(); Method turnAround()
  6. 6. Command in ProdigyView The Chain-of-responsibility is implemented in ProdigyView by extending the PVApplication or PVStaticApplication.Extend PVApplicationRequired abstract function
  7. 7. Command InterpreterSo genius, you have a class that is full of protected methodsand no way to access them, how are we going to call them?Well notice that our class extends PVApplication.PVApplication contains a public method called thecommandInterpreter. The first argument will be the name ofthe method to execute. Any other arguments after that will bepassed to the method.PVApplication is an abstract class and the only method that isrequired for you to implement is the defaultFunction(). Thiswill execute if no command is found. Let’s run somecommands.
  8. 8. Command Interpreter ExampleThe method that will be called The arguements passed to the method
  9. 9. Command Interpreter ResultsThe results from passing those commands should looklike this.
  10. 10. The Not So Obvious1. PVApplication extends PVObject which extends PVPatterns. This means any object that extends PVApplication with has use of all the other design patterns as well the PVObject’s collections.2. An object that extends PVApplication can be used as a stand alone object or be integrated in ProdigyView’s application system.
  11. 11. Challenge!This is an optional challenge designed to help you betterunderstand the design pattern.Create two classes that both have only protected methodsand extends PVApplication or PVStaticApplication. Createat least 3 methods in each class.Start the chain by calling one of the object’s commandinterpreter, and have each method call the other objectscommand interpreter until the default function is reached.
  12. 12. Summary1. Have an object extend PVApplication2. Create methods inside that object. They can be protected or public if they are going to be called by the commandInterpreter().3. Execute a method inside that object by using the commandInterpeter and having the first argument passed be the name of the method and any other variables behind it will be passed to the called method as arguments.
  13. 13. API ReferenceFor a better understanding of the Collections and theIterator, check out the api at the two links below.PVApplication More TutorialsFor more tutorials, please visit:http://www.prodigyview.com/tutorials www.prodigyview.com
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×