Command Pattern Chihung Liao Cynthia Jiang. Waiter Order Execute() Hamburger Execute() Hot Dogs Execute() Fries Execute() Cook Make Food()

Slides:



Advertisements
Similar presentations
Module R2 Overview. Process queues As processes enter the system and transition from state to state, they are stored queues. There may be many different.
Advertisements

Chapter 4: The Factory Pattern. Consider the Following Code Fragment Duck duck; if (picnic) { duck = new MallardDuck(); } else if (hunting) { duck = new.
Advanced Programming in Java
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Computer Science 313 – Advanced Programming Topics.
More Interfaces, Dynamic Binding, and Polymorphism Kirk Scott.
Command Pattern 1. Intent Encapsulates a request as an object, thereby letting you parameterize other objects with different requests, queue or log request,
SWE 4743 Strategy Patterns Richard Gesick. CSE Strategy Pattern the strategy pattern (also known as the policy pattern) is a software design.
March Ron McFadyen1 Command The command pattern encapsulates a request or unit of work into an object. An invoker will ask a concrete command.
1 CS 501 Spring 2005 CS 501: Software Engineering Lecture 17 Object Oriented Design 3.
Design Patterns In OPM Presented by: Galia Shlezinger Instructors: Prop. Dov Dori, Dr. Iris Berger.
Software Design & Documentation – Design Pattern: Command Design Pattern: Command Christopher Lacey September 15, 2003.
Feb Ron McFadyen1 Adapter An adapter converts the interface of a class into another interface the client expects. An adapter lets classes work.
Spring 2010ACS-3913 Ron McFadyen1 Command The command pattern encapsulates a request or unit of work into an object. An invoker will ask a concrete command.
March Ron McFadyen1 Singleton pattern Singleton is designed to restrict instantiation of a class to one (or a few) objects. Useful when exactly.
Basic Definitions Data Structures: Data Structures: A data structure is a systematic way of organizing and accessing data. Or, It’s the logical relationship.
GoF Sections 2.7 – 2.9 More Fun with Lexi. Lexi Document Editor Lexi tasks discussed:  Document structure  Formatting  Embellishing the user interface.
Command Pattern When Actions Speak Louder Than Words.
+ Informatics 122 Software Design II Lecture 8 Emily Navarro Duplication of course material for any commercial purpose without the explicit written permission.
BY VEDASHREE GOVINDA GOWDA
Behavioral Patterns  Behavioral patterns are patterns whose purpose is to facilitate the work of algorithmic calculations and communication between classes.
(C) 2010 Pearson Education, Inc. All rights reserved. Java™ How to Program, 8/e.
COMP 410 & Sky.NET May 2 nd, What is COMP 410? Forming an independent company The customer The planning Learning teamwork.
CS 210 Introduction to Design Patterns September 28 th, 2006.
Case Studies on Design Patterns Design Refinements Examples.
Abstract Factory Design Pattern making abstract things.
Design Pattern. The Observer Pattern The Observer Pattern defines a one-to-many dependency between objects so that when one object changes state, all.
Tech Talk Go4 Factory Patterns Presented By: Matt Wilson.
Behavioral Pattern: Command C h a p t e r 5 – P a g e 139 There are times when the need arises to issue a request to an object without knowing anything.
Command. RHS – SOC 2 Executing a command Executing a command appears simple at first, but many details to consider: –Who creates a command? –Who invokes.
Java™ How to Program, 9/e Presented by: Dr. José M. Reyes Álamo © Copyright by Pearson Education, Inc. All Rights Reserved.
1 Command Design Pattern Rick Mercer and Rice University.
CS 210 Introduction to Design Patterns September 26 th, 2006.
Structural Pattern: Bridge When the abstract interface and the concrete implementation have been set up as parallel class hierarchies, it becomes difficult.
Linzhang Wang Dept. of Computer Sci&Tech, Nanjing University The Command Pattern.
Computer Science 313 – Advanced Programming Topics.
Define an interface for creating an object, but let subclasses decide which class to instantiate Factory Method Pattern.
Abstract Factory and Factory Method CS 124 Reference: Gamma et al (“Gang-of-4”), Design Patterns.
Behavioral Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
Workshops 5 & 6 Design Patterns. Composite pattern Make Parts (components) into a Unit (composite) Client.
BEHAVIORAL PATTERNS 13-Sep-2012 Presenters Sanjeeb Kumar Nanda & Shankar Gogada.
Remote Method Invocation by James Hunt, Joel Dominic, and Adam Mcculloch.
Object-Oriented Principals Dwight Deugo Nesa Matic
Example to motivate discussion We have two lists (of menu items) one implemented using ArrayList and another using Arrays. How does one work with these.
Chapter 11: Advanced Inheritance Concepts. Objectives Create and use abstract classes Use dynamic method binding Create arrays of subclass objects Use.
CS 210 Proxy Pattern Nov 16 th, RMI – A quick review A simple, easy to understand tutorial is located here:
CS 5150 Software Engineering Lecture 16 Program Design 3.
Reference – Object Oriented Software Development Using Java - Jia COP 3331 Object Oriented Analysis and Design Chapter 10 – Patterns Jean Muhammad.
I Like Ike I have always found that plans are useless, but planning is indispensable.
The Command Pattern SE-2811 Dr. Mark L. Hornick 1.
Command. RHS – SWC 2 Executing a command Executing a command appears simple at first, but many details to consider: –Who creates a command? –Who invokes.
STRATEGY PATTERN By Michelle Johnson. BACKGROUND Behavioral Pattern Allow you to define a family of algorithms, encapsulate each one, and make them interchangeable.
1 Inheritance One of the goals of object oriented programming is code reuse. Inheritance is one mechanism for accomplishing code reuse. It allows us to.
Command Pattern. Intent encapsulate a request as an object  can parameterize clients with different requests, queue or log requests, support undoable.
Sections Inheritance and Abstract Classes
OOP: Encapsulation &Abstraction
Structural Patterns Structural patterns control the relationships between large portions of your applications. Structural patterns affect applications.
Behavioral Design Patterns
More Interfaces, Dynamic Binding, and Polymorphism
Singleton Pattern Command Pattern
Command Pattern.
Doug Jeffries CS490 Design Patterns May 1, 2003
Command Pattern 1.
Command Design Pattern
State Design Pattern 1.
Behavioral Patterns Part-I introduction UNIT-VI
PH Chapter 3 Thanks for the Memory Leaks Pushme-Pullyu (pp
BRIDGE PATTERN.
The Command Design Pattern
Presentation transcript:

Command Pattern Chihung Liao Cynthia Jiang

Waiter Order Execute() Hamburger Execute() Hot Dogs Execute() Fries Execute() Cook Make Food()

Hamburger Execute() Hot Dog Execute() Fries Execute() Abstract command (superclass) Concrete command (subclass) Order Execute()

Client Invoker Command Execute() Receiver Action() ConcreteCommand Execute() State

Flexibility and Extensibility Encapsulate a request as an object Compare to C function pointer Decouple the client and receiver by the invoker who ONLY invoke an operation Any request can be cancelled or added in form of stack Request to be executed can be stored as a queue

Translate into JAVA 1 Interface Command: an interface for executing an operation (it could also be an abstract class, refer to the sample code’s comment) Class Client: creates a ConcreteCommand object and set its receiver Class Receiver: who actually DOES things

Translate into JAVA 2 Class Invoker: ask Command to carry out an execution, an agent between ConcreteCommand and Client Class ConcreteCommand implements Command: MUST have the method in Interface Command

QUESTIONS