March 200692.3913 Ron McFadyen1 Command The command pattern encapsulates a request or unit of work into an object. An invoker will ask a concrete command.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming
Advertisements

Mari Göransson - KaU - Datavetenskap - DAVD11 1 Java Event Handling --
Winter 2007ACS-3913 Ron McFadyen1 Duck Example Consider the text example (up to page 6). Each type of duck is a subclass of Duck Most subclasses implement.
Winter 2007ACS-3913 Ron McFadyen1 Also known as publish/subscribe The essence of this pattern is that one or more objects (called observers or listeners)
Command Explained. Intent Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests,
Command Pattern 1. Intent Encapsulates a request as an object, thereby letting you parameterize other objects with different requests, queue or log request,
Oct Ron McFadyen1 Collaborations Collaboration : an arrangement of classes, links, roles in a context to implement some behaviour. Name of.
March Ron McFadyen1 Design Patterns In software engineering, a design pattern is a generally repeatable solution to a commonly-occurring problem.
Fall 2009ACS-3913 Ron McFadyen1 Decorator Pattern The Decorator pattern allows us to enclose an object inside another object. The enclosing object is called.
Feb Ron McFadyen1 Iterator Pattern Recall Generic UML class diagram The iterator is used to access the elements of some aggregate. The aggregate.
Spring 2010ACS-3913 Ron McFadyen1 Weather Station Page 39+ In this application, weather station devices supply data to a weather data object. As the data.
Jan 2005 Ron McFadyen1 Contracts Used to help understand requirements more completely (and so may not always be necessary) based on assertions;
Fall 2008ACS-1805 Ron McFadyen1 ACS-1805 Introduction to Programming using Alice 2.0 Ron McFadyen Course OutlineMcFadyenOutline.
Automating Tasks With Macros
Sept 2004Ron McFadyen Decorator Pattern The decorator pattern allows us to enclose an object inside another object. The enclosing object is called.
Fall 2007ACS Ron McFadyen1 Composite Pattern (see pages ) A composite is a group of objects in which some objects contain others; one object.
The Switchboard User Interface. Prof. Leighton2 User Friendly Databases Create an attractive main menu Help the database users maneuver through the database.
Spring 2010ACS-3913 Ron McFadyen1 Command The complex remote control (many pairs of buttons; null command) Undo … pages 216+ Macro … pages 224+
Feb Ron McFadyen1 Adapter An adapter converts the interface of a class into another interface the client expects. An adapter lets classes work.
Fall 2009ACS Ron McFadyen1 The context maintains an instance of a concrete state subclass State Pattern Each subclass (concrete state) implements.
Winter 2012ACS-3913 Ron McFadyen1 Model View Controller Originated with Smalltalk development (1979) Separates a system’s classes into View, Controller,
March Ron McFadyen1 Design Patterns In software engineering, a design pattern is a generally repeatable solution to a commonly-occurring problem.
Automating Tasks With Macros. 2 Design a switchboard and dialog box for a graphical user interface Database developers interact directly with Access.
March Ron McFadyen1 Using Rational Rose to create a database.
Command Pattern Chihung Liao Cynthia Jiang. Waiter Order Execute() Hamburger Execute() Hot Dogs Execute() Fries Execute() Cook Make Food()
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.
Feb Ron McFadyen1 Iterator Pattern Generic UML class diagram The iterator is used to access the elements of some aggregate. The aggregate interface.
Oct Ron McFadyen1 Collaborations Collaboration : an arrangement of classes, links, roles in a context to implement some behaviour. Useful for.
Winter 2007ACS-3913 Ron McFadyen1 Observer Pattern Problem: There are many objects (observers / subscribers) needing to know of the state changes, or events,
Winter 2011ACS Ron McFadyen1 Façade A façade simplifies access to a related set of objects by providing one object that all objects outside the.
March Ron McFadyen1 Singleton pattern Singleton is designed to restrict instantiation of a class to one (or a few) objects. Useful when exactly.
Command Design Pattern Source: Design Patterns – Elements of Reusable Object- Oriented Software; Gamma, et. al.
Spring 2010ACS-3913 Ron McFadyen1 Duck Example Consider the text example (up to page 6). Each type of duck is a subclass of Duck Most subclasses implement.
Command Pattern When Actions Speak Louder Than Words.
BY VEDASHREE GOVINDA GOWDA
Design Patterns and Graphical User Interfaces Horstmann ,
CS 210 Introduction to Design Patterns September 28 th, 2006.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. C H A P T E R T E N Event-Driven Programming.
Week 2 Lab1 User Interface Design Dina A. Said
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.
1 Command Design Pattern Rick Mercer and Rice University.
CS 210 Introduction to Design Patterns September 26 th, 2006.
1 Command Design Pattern Rick Mercer. Command Design Pattern The Command Pattern encapsulates a request as an object, thereby letting you queue commands,
An Introduction to Programming and Object Oriented Design using Java 3 rd Edition. Dec 2007 Jaime Niño Frederick Hosch Chapter 18 Integrating user interface.
November Ron McFadyen1 Composite Pattern A composite is a group of objects in which some objects contain others; one object may represent groups,
Object Oriented Programming.  Interface  Event Handling.
March R McFadyen1 Object Relational Mapping example TopLink Part of Oracle environment Provides an Object/Relational Mapping Layer References:
Slides prepared by Rose Williams, Binghamton University ICS201 Lecture 15 : Swing III King Fahd University of Petroleum & Minerals College of Computer.
Fall 2008ACS-1805 Ron McFadyen1 Event-driven programming Chapter 5 covers event-driven programming. Events are user or condition driven and so each event.
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.
Command Pattern Encapsulation Invocation. One size fits all.
Jan Ron McFadyen1 Use Cases Used to capture functional requirements – there are other requirements categories such as usability, reliability,
Prepared by: Dr. Abdallah Mohamed, AOU-KW Unit7: Event-driven programming 1.
Command Pattern. Intent encapsulate a request as an object  can parameterize clients with different requests, queue or log requests, support undoable.
Façade Pattern:.
Singleton Pattern Command Pattern
Command Pattern.
Programming Design Patterns
Doug Jeffries CS490 Design Patterns May 1, 2003
Command Pattern 1.
Command Design Pattern
תכן UML in Design מקורות: S. R. Schach: Chapter 12
State Design Pattern 1.
Graphical User Interfaces in Java Event-driven programming
DESIGN PATTERNS : State Pattern
Constructors, GUI’s(Using Swing) and ActionListner
The Command Design Pattern
defines a higher-level interface that makes a subsystem easier to use
Event-driven programming
Presentation transcript:

March Ron McFadyen1 Command The command pattern encapsulates a request or unit of work into an object. An invoker will ask a concrete command to perform its function and the concrete command will in turn ask some receiver to perform a pre-determined action.

March Ron McFadyen2 Command – generic class diagram «Interface» Command Concrete Command Receiver Invoker Command Concrete commandreceiver command action1() action2() execute() setCommand() invoker

March Ron McFadyen3 Command – text example «Interface » Command lightOn Command Light Remote control Command Concrete command receiver command on() off() execute() setCommand() invoker lightOff Command execute() Concrete command null Command execute() Concrete command

March Ron McFadyen4 Command - behaviour :Light:RemoteControl execute() lightOn() execute() lightOff() :LightOn Command :LightOff Command :null Command execute()

March Ron McFadyen5 Command Example: User interfaces typically give you ways to issue a particular command Java Swing classes use the command pattern to perform application-specific functionality. Action objects are used. Button classes, menu items, etc. maintain a reference to an action defined by the Action interface. Whenever a Swing component activates, it calls its action’s (command’s) actionPerformed() method (execute() method).

March Ron McFadyen6 Command Example: Consider the handout having to do with executing transactions in an SQL environment