SlideShare a Scribd company logo
1 of 74
Design Patterns 05/28/10 Week 4: Command and Adapter Jonathan Simon [email_address]
Agenda ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Remote Control ,[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
First Thoughts ,[object Object],[object Object],[object Object],05/28/10
What Varies?  What stays the same? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
The Vendor Classes (pg 194) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
One possible solution… ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10 Problems: The Remote needs to be aware of all the details about turning a device on (or off). If device On/Off mechanism changes, the Remote code will need to be changed. If a new device is added, this code would need to be changed. Is this Open for Extension?? Also…what about undo????
Separation of Concerns ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
The Command Pattern ,[object Object],[object Object],[object Object],05/28/10
Command Interface (pg203) ,[object Object],[object Object],[object Object],[object Object],05/28/10
LightOnCommand (pg203) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10 The command is composed of a vendor class. Constructor  takes the vendor class as parameter. Here the command  delegates execution to the vendor class.  Note : This is a simple example..there could be more steps.
SimpleRemoteControl (pg204) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10 This version of the remote just has one slot. setCommand assigns a Command to a slot. Tells the command to execute. Note that any command would work here.  The remote doesn’t know anything about the specific vendor class.
RemoteControlTest (pg204) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10 Create two vendor classes. Create two commands based on these vendor classes. Set the command and press button
The Command Pattern ,[object Object],[object Object],[object Object],[object Object],05/28/10
Definitions (see Diagram on pg 207) ,[object Object],[object Object],[object Object],[object Object],[object Object]
Lab Part I ,[object Object],[object Object],05/28/10
Lab Part II ,[object Object],[object Object],05/28/10
Lab Part III (Design Challenge!) ,[object Object],[object Object],[object Object],05/28/10
Lab Part I Answer ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Lab Part I Answer (cont) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Lab Part II  Answer ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Lab Part III (Answer) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Lab Part III (Answer) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],We don’t want on(), off(), and undo() to be overridden.
Lab Part III ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Lab Part III ,[object Object],[object Object],[object Object],[object Object],05/28/10
History of Undo Operations ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
History of Undo Operations ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Simple Logging ,[object Object],[object Object],05/28/10
Simple Logging ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10 Advantage: We can add logging in the Invoker. No change is needed in any of the Command or Receiver objects!
Complex Logging ,[object Object],[object Object],[object Object],05/28/10
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Complex Logging  05/28/10 Once again, we can make these changes in one place (the Invoker)
Case Study: Command Management 05/28/10 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Question ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Possible Solutions ,[object Object],[object Object],[object Object],05/28/10
Disadvantages ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Command Management Framework ,[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Command Manager 05/28/10 The Commands property contains a list of all possible Commands. CommandsList contains a List object internally for storing each possible Command.  It also has a reference to CommandManager.
Command Object ExecuteHandler = delegate that represents the logic for executing the actual Command logic.  Triggered when the command is executed. Gets associated with OnExecute event. UpdateHandler = delegate that represents the logic for executing the logic to update the state of a command. (For example, Edit    Copy should be enabled if text has been selected).  Associated with OnUpdate event.
Command Constructor ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10 Associates events to delegates
Command: Execute() and ProcessUpdates() ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Will call the function passed in as ExecuteHandler Will call the function passed in as UpdateHandler How is this Command.Execute() different than the RemoteControl example??
Re-look at EditCopy ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10 Will discuss later
So far.. 05/28/10 Command #1 Tag = “Edit Copy” OnExecute = OnCopy OnUpdate =  UpdateCopyCommand Command #2 Tag = “File Open” OnExecute = OnFileOpen OnUpdate =  null
Associating UI Elements to a Command ,[object Object],[object Object],[object Object],[object Object],05/28/10 What object contains the CommandInstances property??
CommandInstances 05/28/10 Contain a list of all UI Elements associated with a Command
So far.. 05/28/10 Command #1 Tag = “Edit Copy” OnExecute = OnCopy OnUpdate =  UpdateCopyCommand Two items: mnuEditCopy tlbMain.Buttons[4] All we have done so far is store information…
How do we enable a Command??? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Are you enabled???
Command.ProcessUpdates() ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10 If we do need to enable (or disable) the Command, who do we need to tell to “go enable/disable yourself?”
Command.Enabled Property ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Command.Enabled (Psuedo-Code) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10 Question:  Any problems with this code???
Command.Enabled (Psuedo-Code) ,[object Object],[object Object],[object Object],[object Object],05/28/10
CommandExecutor 05/28/10 Enable() is abstract.  Toolbar and Menu subclasses must define how Enable needs to work.
CommandExecutor ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Command.Enabled (Real Code) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],CommandManager actually contains all possible CommandExecutors. These are registered during start-up for each possible type of UI element. (CommandManager constructor)
CommandExecutor - Execution ,[object Object],[object Object],05/28/10
MenuCommandExecutor ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10 Called when we added UI element to Command
Example (Again) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Confused? ,[object Object],[object Object],05/28/10
Distributed Command Pattern ,[object Object],[object Object],05/28/10
Adapter Pattern ,[object Object],[object Object],05/28/10
Real Life Examples ,[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Drawback ,[object Object],[object Object],05/28/10
Example 1 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10 Generated Code!!!
Example 1 ,[object Object],[object Object],[object Object],[object Object],05/28/10 Imagine these lines of code were in different parts of the system. What happens when SaveCustomer gets re-generated?
Example 1 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Lab ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Lab ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Lab ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Lab ,[object Object],[object Object],05/28/10
Answer: Two Way Adapter ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Answer ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Answer ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10
Answer: Reworked Code ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],05/28/10

More Related Content

What's hot

Observer design pattern
Observer design patternObserver design pattern
Observer design pattern
Sara Torkey
 
32 e lrng tchr edctrs - how to guide use hot potatoes j quiz
32 e lrng tchr edctrs - how to guide use hot potatoes j quiz32 e lrng tchr edctrs - how to guide use hot potatoes j quiz
32 e lrng tchr edctrs - how to guide use hot potatoes j quiz
hyesayan
 
Singleton design pattern
Singleton design patternSingleton design pattern
Singleton design pattern
11prasoon
 

What's hot (20)

Pembuatan AR Menggunakan Unity dan Vuforia
Pembuatan AR Menggunakan Unity dan VuforiaPembuatan AR Menggunakan Unity dan Vuforia
Pembuatan AR Menggunakan Unity dan Vuforia
 
Observer design pattern
Observer design patternObserver design pattern
Observer design pattern
 
Design Pattern - Singleton Pattern
Design Pattern - Singleton PatternDesign Pattern - Singleton Pattern
Design Pattern - Singleton Pattern
 
32 e lrng tchr edctrs - how to guide use hot potatoes j quiz
32 e lrng tchr edctrs - how to guide use hot potatoes j quiz32 e lrng tchr edctrs - how to guide use hot potatoes j quiz
32 e lrng tchr edctrs - how to guide use hot potatoes j quiz
 
Template skpl 9 11 2015
Template skpl 9 11 2015Template skpl 9 11 2015
Template skpl 9 11 2015
 
Proxy Design Pattern
Proxy Design PatternProxy Design Pattern
Proxy Design Pattern
 
The Singleton Pattern Presentation
The Singleton Pattern PresentationThe Singleton Pattern Presentation
The Singleton Pattern Presentation
 
Design pattern-presentation
Design pattern-presentationDesign pattern-presentation
Design pattern-presentation
 
Chain of responsibility
Chain of responsibilityChain of responsibility
Chain of responsibility
 
Chain of responsibility
Chain of responsibilityChain of responsibility
Chain of responsibility
 
Memento pattern
Memento patternMemento pattern
Memento pattern
 
Software Architecture - Quiz Questions
Software Architecture - Quiz QuestionsSoftware Architecture - Quiz Questions
Software Architecture - Quiz Questions
 
Factory Design Pattern
Factory Design PatternFactory Design Pattern
Factory Design Pattern
 
Design pattern (Abstract Factory & Singleton)
Design pattern (Abstract Factory & Singleton)Design pattern (Abstract Factory & Singleton)
Design pattern (Abstract Factory & Singleton)
 
Modul MySQL TIngkat Lanjut
Modul MySQL TIngkat LanjutModul MySQL TIngkat Lanjut
Modul MySQL TIngkat Lanjut
 
Singleton design pattern
Singleton design patternSingleton design pattern
Singleton design pattern
 
Simulation & Modeling - Smilulation Queuing System
Simulation & Modeling - Smilulation Queuing SystemSimulation & Modeling - Smilulation Queuing System
Simulation & Modeling - Smilulation Queuing System
 
Sequence Diagram
Sequence DiagramSequence Diagram
Sequence Diagram
 
Proposal KAK Sistem Informasi Posko Keamanan
Proposal KAK Sistem Informasi Posko KeamananProposal KAK Sistem Informasi Posko Keamanan
Proposal KAK Sistem Informasi Posko Keamanan
 
Dokumen perencanaan proyek
Dokumen perencanaan proyekDokumen perencanaan proyek
Dokumen perencanaan proyek
 

Viewers also liked

Model View Command Pattern
Model View Command PatternModel View Command Pattern
Model View Command Pattern
Akash Kava
 
Android ui adapter
Android ui adapterAndroid ui adapter
Android ui adapter
Krazy Koder
 
Retail Institution Report
Retail Institution ReportRetail Institution Report
Retail Institution Report
Fridz Felisco
 

Viewers also liked (20)

Strategy and Template Pattern
Strategy and Template PatternStrategy and Template Pattern
Strategy and Template Pattern
 
MVC and Other Design Patterns
MVC and Other Design PatternsMVC and Other Design Patterns
MVC and Other Design Patterns
 
Command Design Pattern
Command Design PatternCommand Design Pattern
Command Design Pattern
 
Design patterns - Singleton&Command
Design patterns - Singleton&CommandDesign patterns - Singleton&Command
Design patterns - Singleton&Command
 
Introduction to Design Patterns and Singleton
Introduction to Design Patterns and SingletonIntroduction to Design Patterns and Singleton
Introduction to Design Patterns and Singleton
 
Factory and Abstract Factory
Factory and Abstract FactoryFactory and Abstract Factory
Factory and Abstract Factory
 
Command pattern
Command patternCommand pattern
Command pattern
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
 
Command Design Pattern
Command Design PatternCommand Design Pattern
Command Design Pattern
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
 
"Pushing the boundaries" por @danielguillan
"Pushing the boundaries" por @danielguillan"Pushing the boundaries" por @danielguillan
"Pushing the boundaries" por @danielguillan
 
Command Pattern
Command PatternCommand Pattern
Command Pattern
 
Model View Command Pattern
Model View Command PatternModel View Command Pattern
Model View Command Pattern
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Android ui adapter
Android ui adapterAndroid ui adapter
Android ui adapter
 
Android sync adapter
Android sync adapterAndroid sync adapter
Android sync adapter
 
Decorator design pattern
Decorator design patternDecorator design pattern
Decorator design pattern
 
Client-Server-Kommunikation mit dem Command Pattern
Client-Server-Kommunikation mit dem Command PatternClient-Server-Kommunikation mit dem Command Pattern
Client-Server-Kommunikation mit dem Command Pattern
 
Retail Institution Report
Retail Institution ReportRetail Institution Report
Retail Institution Report
 
Design Patterns - 03 Composite and Flyweight Pattern
Design Patterns - 03 Composite and Flyweight PatternDesign Patterns - 03 Composite and Flyweight Pattern
Design Patterns - 03 Composite and Flyweight Pattern
 

Similar to Command and Adapter Pattern

Print Testing
Print TestingPrint Testing
Print Testing
donwelch
 
Convergence
ConvergenceConvergence
Convergence
donwelch
 
15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docx
15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docx15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docx
15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docx
felicidaddinwoodie
 
Refactoring Simple Example
Refactoring Simple ExampleRefactoring Simple Example
Refactoring Simple Example
liufabin 66688
 

Similar to Command and Adapter Pattern (20)

Session2-J2ME development-environment
Session2-J2ME development-environmentSession2-J2ME development-environment
Session2-J2ME development-environment
 
Eclipse Summit Europe '10 - Test UI Aspects of Plug-ins
Eclipse Summit Europe '10 - Test UI Aspects of Plug-insEclipse Summit Europe '10 - Test UI Aspects of Plug-ins
Eclipse Summit Europe '10 - Test UI Aspects of Plug-ins
 
Contiki Operating system tutorial
Contiki Operating system tutorialContiki Operating system tutorial
Contiki Operating system tutorial
 
Print Testing
Print TestingPrint Testing
Print Testing
 
Convergence
ConvergenceConvergence
Convergence
 
Implementing of classical synchronization problem by using semaphores
Implementing of classical synchronization problem by using semaphoresImplementing of classical synchronization problem by using semaphores
Implementing of classical synchronization problem by using semaphores
 
MicroPython for LEGO Spike - introduction
MicroPython for LEGO Spike - introductionMicroPython for LEGO Spike - introduction
MicroPython for LEGO Spike - introduction
 
15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docx
15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docx15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docx
15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docx
 
Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)
 
Taming startup dynamics - Magnus Jungsbluth & Domagoj Cosic
Taming startup dynamics - Magnus Jungsbluth & Domagoj CosicTaming startup dynamics - Magnus Jungsbluth & Domagoj Cosic
Taming startup dynamics - Magnus Jungsbluth & Domagoj Cosic
 
PART-2 : Mastering RTOS FreeRTOS and STM32Fx with Debugging
PART-2 : Mastering RTOS FreeRTOS and STM32Fx with DebuggingPART-2 : Mastering RTOS FreeRTOS and STM32Fx with Debugging
PART-2 : Mastering RTOS FreeRTOS and STM32Fx with Debugging
 
Refactoring Simple Example
Refactoring Simple ExampleRefactoring Simple Example
Refactoring Simple Example
 
CH05.pdf
CH05.pdfCH05.pdf
CH05.pdf
 
WHQL USB DTM Quick Start How-to
WHQL USB DTM Quick Start How-toWHQL USB DTM Quick Start How-to
WHQL USB DTM Quick Start How-to
 
QEMU - Binary Translation
QEMU - Binary Translation QEMU - Binary Translation
QEMU - Binary Translation
 
Loops_and_FunctionsWeek4_0.ppt
Loops_and_FunctionsWeek4_0.pptLoops_and_FunctionsWeek4_0.ppt
Loops_and_FunctionsWeek4_0.ppt
 
myslide1
myslide1myslide1
myslide1
 
myslide6
myslide6myslide6
myslide6
 
NewSeriesSlideShare
NewSeriesSlideShareNewSeriesSlideShare
NewSeriesSlideShare
 
Microkernel Development
Microkernel DevelopmentMicrokernel Development
Microkernel Development
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 

Command and Adapter Pattern

  • 1. Design Patterns 05/28/10 Week 4: Command and Adapter Jonathan Simon [email_address]
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39. Command Manager 05/28/10 The Commands property contains a list of all possible Commands. CommandsList contains a List object internally for storing each possible Command. It also has a reference to CommandManager.
  • 40. Command Object ExecuteHandler = delegate that represents the logic for executing the actual Command logic. Triggered when the command is executed. Gets associated with OnExecute event. UpdateHandler = delegate that represents the logic for executing the logic to update the state of a command. (For example, Edit  Copy should be enabled if text has been selected). Associated with OnUpdate event.
  • 41.
  • 42.
  • 43.
  • 44. So far.. 05/28/10 Command #1 Tag = “Edit Copy” OnExecute = OnCopy OnUpdate = UpdateCopyCommand Command #2 Tag = “File Open” OnExecute = OnFileOpen OnUpdate = null
  • 45.
  • 46. CommandInstances 05/28/10 Contain a list of all UI Elements associated with a Command
  • 47. So far.. 05/28/10 Command #1 Tag = “Edit Copy” OnExecute = OnCopy OnUpdate = UpdateCopyCommand Two items: mnuEditCopy tlbMain.Buttons[4] All we have done so far is store information…
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53. CommandExecutor 05/28/10 Enable() is abstract. Toolbar and Menu subclasses must define how Enable needs to work.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.

Editor's Notes

  1. 13 November 2008
  2. Note: In the RemoteControl example, each Command wrapped a Receiver object and told the Reciever to do something. In this example, the Command is given the logic externally. 13 November 2008
  3. Possible Side Discussion on Factory? 13 November 2008