State Design Pattern 1.

Slides:



Advertisements
Similar presentations
By : Atri Chatterjee Souvik Ghosh
Advertisements

GoF State Pattern Aaron Jacobs State(305) Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.
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.
Computer Science 313 – Advanced Programming Topics.
SWE 4743 Strategy Patterns Richard Gesick. CSE Strategy Pattern the strategy pattern (also known as the policy pattern) is a software design.
Matt Klein 7/6/2009.  Behavioral Pattern  Intent  Allow an object to alter its behavior when its internal state changes. The object will appear to.
March Ron McFadyen1 Command The command pattern encapsulates a request or unit of work into an object. An invoker will ask a concrete command.
BehavioralCmpE196G1 Behavioral Patterns Chain of Responsibility (requests through a chain of candidates) Command (encapsulates a request) Interpreter (grammar.
Fall 2009ACS Ron McFadyen1 The context maintains an instance of a concrete state subclass State Pattern Each subclass (concrete state) implements.
ECE 355 Design Patterns Tutorial Part 3 Presented by Igor Ivković
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.
Spring 2010CS 2251 Design Patterns. Spring 2010CS 2252 What is a Design Pattern? "a general reusable solution to a commonly occurring problem in software.
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.
Behavioral Patterns C h a p t e r 5 – P a g e 128 BehavioralPatterns Design patterns that identify and realize common interactions between objects Chain.
Case Studies on Design Patterns Design Refinements Examples.
Design Pattern. The Observer Pattern The Observer Pattern defines a one-to-many dependency between objects so that when one object changes state, all.
 How are you going to collaborate?  How are you going to divide up work?  How are you going to make sure that changes work with other people’s code?
Behavioral Design Patterns Morteza Yousefi University Of Science & Technology Of Mazandaran 1of 27Behavioral Design Patterns.
Strategy Design Patterns CS 590L - Sushil Puradkar.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns VIII Chain of Responsibility, Strategy, State.
Design Patterns Definition:
Refactoring II Dealing with Polymorphism. Switch in Rental Switches on Movie! class Rental … public double getCharge() { double result = 0; switch (getMovie().getPriceCode()){
FacadeDesign Pattern Provide a unified interface to a set of interfaces in a subsystem. Defines a high level interface that makes the subsystem easier.
Design Patterns By Mareck Kortylevitch and Piotreck Ratchinsky.
Behavioral Patterns1 Nour El Kadri SEG 3202 Software Design and Architecture Notes based on U of T Design Patterns class.
An Introduction To Design Patterns Jean-Paul S. Boodhoo Independent Consultant
© 2006 Pearson EducationDesign Patterns1 of 20 A Final Example: A Traffic Light Let’s model a traffic light! – here’s the spec: Have a column of two circles.
BEHAVIORAL PATTERNS 13-Sep-2012 Presenters Sanjeeb Kumar Nanda & Shankar Gogada.
The State Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
Stéphane Ducasse 1 Strategy.
STATE PATTERN Presented by Bharavi Mishra Bharavi Mishraise
Deriving State…...and an example of combining behaviour.
The Strategy Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
Decorator Design Pattern Phillip Shin. Overview Problem Solution Example Key points.
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.
Patterns are Roles What patterns are and what not…
An object's behavior depends on its current state. Operations have large, multipart conditional statements that depend on the object's state.
STRATEGY PATTERN By Michelle Johnson. BACKGROUND Behavioral Pattern Allow you to define a family of algorithms, encapsulate each one, and make them interchangeable.
The State Design Pattern A behavioral design pattern. Shivraj Persaud
Command Pattern. Intent encapsulate a request as an object  can parameterize clients with different requests, queue or log requests, support undoable.
Factory Method Pattern. Admin SCPI Patner Day Feb. 21 Lunch count Presentation (4-8 min.) Practice on Feb. 16. Morning availablity on Feb21 Brief overview.
Design Patterns: MORE Examples
Strategy: A Behavioral Design Pattern
Strategy Design Pattern
Façade Pattern:.
Chapter Nine The Strategy Pattern
Behavioral Design Patterns
Software Design and Architecture
State pattern – A logical ‘Finite State Machine’
Design Patterns with C# (and Food!)
Mediator Design Pattern (Behavioral)
Introduction to Behavioral Patterns (2)
Prototype Pattern 1.
Flyweight Pattern 1.
BRIDGE PATTERN.
DESIGN PATTERNS : State Pattern
State Design Pattern Brandon Jacobsen.
Structural Patterns: Adapter and Bridge
State Pattern By the Group of Four.
Strategy Design Pattern
Introduction to Design Patterns
ECE 355 Design Patterns Tutorial Part 3
Design by Abstraction (Continuation) CS 3331 Spring 2005
Decorator Pattern.
Adapter Pattern Jim Fawcett
Software Design Lecture : 28.
Software Engineering and Architecture
Adapter Pattern Jim Fawcett
Presentation transcript:

State Design Pattern 1

State Pattern Intent Allow an object to alter its behavior when its internal state changes The object will appear to change its class

<<interface>> Class Diagram The State interface defines a common interface for all concrete states; the states all implement the same interface so that are interchangeable. <<interface>> State Context Request() Handle() ConcreteStateA ConcreteStateB state.Handle() Handle() Handle() Whenever the request() is made on the Context it is delegated to the state to handle ConcreteStates handle requests from the Context. Each ConcreteState provides its own implementation for a request. In this way, when the Context changes state, its behavior will change as well.

Participants Context State ConcreteState Defines the interface of interest to the clients Maintains an instance of a ConcreteState subclass that defines the current state State Defines an interface for encapsulating the behavior associated with a particular State of the Context ConcreteState Each subclass implements a behavior associated with a State of the Context

?

References