SlideShare uma empresa Scribd logo
1 de 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

Mais conteúdo relacionado

Mais procurados

Iterative control structures, looping, types of loops, loop working
Iterative control structures, looping, types of loops, loop workingIterative control structures, looping, types of loops, loop working
Iterative control structures, looping, types of loops, loop workingNeeru Mittal
 
Android share preferences
Android share preferencesAndroid share preferences
Android share preferencesAjay Panchal
 
Control structures in java
Control structures in javaControl structures in java
Control structures in javaVINOTH R
 
MVC Architecture
MVC ArchitectureMVC Architecture
MVC ArchitecturePrem Sanil
 
Introduction to Selection control structures in C++
Introduction to Selection control structures in C++ Introduction to Selection control structures in C++
Introduction to Selection control structures in C++ Neeru Mittal
 
JSP Components and Directives.pdf
JSP Components and Directives.pdfJSP Components and Directives.pdf
JSP Components and Directives.pdfArumugam90
 
C# Delegates and Event Handling
C# Delegates and Event HandlingC# Delegates and Event Handling
C# Delegates and Event HandlingJussi Pohjolainen
 
Pointers,virtual functions and polymorphism cpp
Pointers,virtual functions and polymorphism cppPointers,virtual functions and polymorphism cpp
Pointers,virtual functions and polymorphism cpprajshreemuthiah
 
08 state diagram and activity diagram
08 state diagram and activity diagram08 state diagram and activity diagram
08 state diagram and activity diagramBaskarkncet
 
Iterator Design Pattern
Iterator Design PatternIterator Design Pattern
Iterator Design PatternVarun Arora
 

Mais procurados (20)

Iterative control structures, looping, types of loops, loop working
Iterative control structures, looping, types of loops, loop workingIterative control structures, looping, types of loops, loop working
Iterative control structures, looping, types of loops, loop working
 
Pointer in c++ part1
Pointer in c++ part1Pointer in c++ part1
Pointer in c++ part1
 
Android share preferences
Android share preferencesAndroid share preferences
Android share preferences
 
Delegates and events
Delegates and events   Delegates and events
Delegates and events
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Control structures in java
Control structures in javaControl structures in java
Control structures in java
 
MVC Architecture
MVC ArchitectureMVC Architecture
MVC Architecture
 
Introduction to Selection control structures in C++
Introduction to Selection control structures in C++ Introduction to Selection control structures in C++
Introduction to Selection control structures in C++
 
Arrays in java
Arrays in javaArrays in java
Arrays in java
 
JSP Components and Directives.pdf
JSP Components and Directives.pdfJSP Components and Directives.pdf
JSP Components and Directives.pdf
 
Structure in c sharp
Structure in c sharpStructure in c sharp
Structure in c sharp
 
7.data types in c#
7.data types in c#7.data types in c#
7.data types in c#
 
C# Delegates and Event Handling
C# Delegates and Event HandlingC# Delegates and Event Handling
C# Delegates and Event Handling
 
Pointers,virtual functions and polymorphism cpp
Pointers,virtual functions and polymorphism cppPointers,virtual functions and polymorphism cpp
Pointers,virtual functions and polymorphism cpp
 
08 state diagram and activity diagram
08 state diagram and activity diagram08 state diagram and activity diagram
08 state diagram and activity diagram
 
Iterator Design Pattern
Iterator Design PatternIterator Design Pattern
Iterator Design Pattern
 
Windowforms controls c#
Windowforms controls c#Windowforms controls c#
Windowforms controls c#
 
exception handling
exception handlingexception handling
exception handling
 
Java constructors
Java constructorsJava constructors
Java constructors
 
Java awt
Java awtJava awt
Java awt
 

Destaque

Strategy and Template Pattern
Strategy and Template PatternStrategy and Template Pattern
Strategy and Template PatternJonathan Simon
 
MVC and Other Design Patterns
MVC and Other Design PatternsMVC and Other Design Patterns
MVC and Other Design PatternsJonathan Simon
 
Command Design Pattern
Command Design PatternCommand Design Pattern
Command Design PatternRothana Choun
 
Design patterns - Singleton&Command
Design patterns - Singleton&CommandDesign patterns - Singleton&Command
Design patterns - Singleton&CommandKai Aras
 
Introduction to Design Patterns and Singleton
Introduction to Design Patterns and SingletonIntroduction to Design Patterns and Singleton
Introduction to Design Patterns and SingletonJonathan Simon
 
Factory and Abstract Factory
Factory and Abstract FactoryFactory and Abstract Factory
Factory and Abstract FactoryJonathan Simon
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Patternguy_davis
 
Command Design Pattern
Command Design PatternCommand Design Pattern
Command Design PatternShahriar Hyder
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design PatternAdeel Riaz
 
"Pushing the boundaries" por @danielguillan
"Pushing the boundaries" por @danielguillan"Pushing the boundaries" por @danielguillan
"Pushing the boundaries" por @danielguillanwebcat
 
Model View Command Pattern
Model View Command PatternModel View Command Pattern
Model View Command PatternAkash Kava
 
Design Patterns
Design PatternsDesign Patterns
Design Patternsppd1961
 
Android ui adapter
Android ui adapterAndroid ui adapter
Android ui adapterKrazy Koder
 
Android sync adapter
Android sync adapterAndroid sync adapter
Android sync adapterAlex Tumanoff
 
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 Patternpgt technology scouting GmbH
 
Retail Institution Report
Retail Institution ReportRetail Institution Report
Retail Institution ReportFridz Felisco
 
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 Patterneprafulla
 

Destaque (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
 

Semelhante a Command and Adapter Pattern

Session2-J2ME development-environment
Session2-J2ME development-environmentSession2-J2ME development-environment
Session2-J2ME development-environmentmuthusvm
 
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-insTonny Madsen
 
Contiki Operating system tutorial
Contiki Operating system tutorialContiki Operating system tutorial
Contiki Operating system tutorialSalah Amean
 
Print Testing
Print TestingPrint Testing
Print Testingdonwelch
 
Convergence
ConvergenceConvergence
Convergencedonwelch
 
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 semaphoresGowtham Reddy
 
MicroPython for LEGO Spike - introduction
MicroPython for LEGO Spike - introductionMicroPython for LEGO Spike - introduction
MicroPython for LEGO Spike - introductionsdoro58
 
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.docxfelicidaddinwoodie
 
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)Hermann Hueck
 
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 Cosicmfrancis
 
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 DebuggingFastBit Embedded Brain Academy
 
Refactoring Simple Example
Refactoring Simple ExampleRefactoring Simple Example
Refactoring Simple Exampleliufabin 66688
 
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-tocamhirundo
 
QEMU - Binary Translation
QEMU - Binary Translation QEMU - Binary Translation
QEMU - Binary Translation Jiann-Fuh Liaw
 
Loops_and_FunctionsWeek4_0.ppt
Loops_and_FunctionsWeek4_0.pptLoops_and_FunctionsWeek4_0.ppt
Loops_and_FunctionsWeek4_0.pptKamranAli649587
 

Semelhante a 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
 

Último

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
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 StreamsRoshan Dwivedi
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
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 2024The Digital Insurer
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
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...apidays
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 

Último (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
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...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

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.

Notas do Editor

  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