A Behavior Object Pattern

Slides:



Advertisements
Similar presentations
UMBC Some Additional Patterns CMSC 432. UMBC More Patterns2 Introduction Over the next few lectures we’ll have an introduction to a number of patterns.
Advertisements

Amirkabir University of Technology, Computer Engineering Faculty, Intelligent Systems Laboratory 1 Mediator Abbas Rasoolzadegan.
OOP Design Patterns Chapters Design Patterns The main idea behind design patterns is to extract the high level interactions between objects and.
Design Pattern: Mediator Mediator Modified from Kyle Kimport’s: Design Patterns: Mediator Design Patterns: Mediator Ref:
Observer Pattern Tu Nguyen. General Purpose When one object changes state, all the dependent objects are notified and updated. Allows for consistency.
BehavioralCmpE196G1 Behavioral Patterns Chain of Responsibility (requests through a chain of candidates) Command (encapsulates a request) Interpreter (grammar.
Façade Pattern Jeff Schott CS590L Spring What is a façade? 1) The principal face or front of a building 2) A false, superficial, or artificial appearance.
Cam Quach Joel Derstine Mediator: Object Behavioral.
Applying Design Patterns to Wireless Sensor Network Sajjad Soroush AmirKabir University of Technology, Department of Computer Engineering.
Mediator A Behavioral Design Pattern for the New Millennium Cory Nugent.
Dept. of Computer Engineering, Amir-Kabir University 1 Design Patterns Dr. Noorhosseini Lecture 2.
Façade Design Pattern Source: Design Patterns – Elements of Reusable Object- Oriented Software; Gamma, et. al.
Chapter 22 Object-Oriented Design
PRESENTED BY SANGEETA MEHTA EECS810 UNIVERSITY OF KANSAS OCTOBER 2008 Design Patterns.
Design Patterns Ric Holt & Sarah Nadi U Waterloo, March 2010.
Seven Habits of Effective Pattern Writers Facade Pattern PH pp GoF pp John Klacsmann.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. The Façade Design Pattern (1) –A structural design pattern.
BY VEDASHREE GOVINDA GOWDA
Vrije Universiteit amsterdamPostacademische Cursus Informatie Technologie Idioms and Patterns polymorphism -- inheritance and delegation idioms -- realizing.
Behavioral Patterns  Behavioral patterns are patterns whose purpose is to facilitate the work of algorithmic calculations and communication between classes.
BDP Behavioral Pattern. BDP-2 Behavioral Patters Concerned with algorithms & assignment of responsibilities Patterns of Communication between Objects.
Design Patterns.
Emeka Egbuonye CSPP March 02,2010 The Mediator Pattern.
Case Studies on Design Patterns Design Refinements Examples.
SOFTWARE DESIGN AND ARCHITECTURE
SWE © Solomon Seifu ELABORATION. SWE © Solomon Seifu Lesson 11 Subsystem Design.
Design Patterns Part two. Structural Patterns Concerned with how classes and objects are composed to form larger structures Concerned with how classes.
Design Pattern. The Observer Pattern The Observer Pattern defines a one-to-many dependency between objects so that when one object changes state, all.
Mediator Pattern and Multiuser Protection Billy Bennett June 8 th, 2009.
Chapter 17 GRASP: Designing Objects with Responsibilities. 1CS6359 Fall 2011 John Cole.
COMP 6471 Software Design Methodologies Winter 2006 Dr Greg Butler
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns IX Interpreter, Mediator, Template Method recap.
Facade Introduction. Intent Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the.
Oct R McFadyen1 Facade P Problem: There are a set of classes, a subsystem, that you need to interact with for some purpose, but you don’t.
Unit 4 Object-Oriented Design Patterns NameStudent Number CAI XIANGHT082182A KYAW THU LINHT082238Y LI PENGFEIHT082220L NAUNG NAUNG LATTHT082195L PLATHOTTAM.
Structural Design Patterns
Mediator Kensho Tsuchihashi. Mediator Page 2 Table of Contents 1.What is Mediator? 2.What problem does Mediator solve? 3.Advantage and Disadvantage 4.Additional.
08 - StructuralCSC4071 Structural Patterns concerned with how classes and objects are composed to form larger structures –Adapter interface converter Bridge.
Structural Patterns1 Nour El Kadri SEG 3202 Software Design and Architecture Notes based on U of T Design Patterns class.
Behavioural Design Patterns Quote du jour: ECE450S – Software Engineering II I have not failed. I've just found 10,000 ways that won't work. - Thomas Edison.
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 Pattern. Definition: A design pattern is a general reusable solution to a commonly occurring problem within a given context in software design.
1 By Rick Mercer with help from Object-Oriented Design Heuristics, Arthur Riel Coupling / Cohesion.
Manali Joshi1 The Observer Design Pattern Presented By: Manali Joshi.
Behavioral Patterns1 Nour El Kadri SEG 3202 Software Design and Architecture Notes based on U of T Design Patterns class.
Design Patterns Introduction
1 Chapter 5:Design Patterns. 2 What are design pattern?  Schematic description of design solution to recurring problems in software design and,  Reusable.
JAVA DESIGN PATTERN Structural Patterns - Facade Pattern Presented by: Amit kumar narela Ise Ise
The Mediator Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
1 Advanced Object-oriented Design – Principles and Patterns Structural Design Patterns.
The Facade Pattern (Structural) ©SoftMoore ConsultingSlide 1.
About the Author A Lifetime of Software Development Started Writing Code at Age 11 Programming Summer Camp at Age 12 Writing Code Ever Since At Age 25,
Watching the movie the hard way…. Page 256 – Head First Design Patterns.
Applying the Principles Two Examples. Example 1 New Requirement It would be nice with a simple GUI “to see something” instead of just xUnit tests...
Behavioral Pattern: Mediator C h a p t e r 5 – P a g e 169 When a program is made up of several classes, the logic and computation is divided among these.
An object's behavior depends on its current state. Operations have large, multipart conditional statements that depend on the object's state.
OBSERVER PATTERN OBSERVER PATTERN Presented By Presented By Ajeet Tripathi ISE
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
Facade Pattern Jim Fawcett CSE776 – Design Patterns Summer 2010
Presented by FACADE PATTERN
Software Design Refinement Using Design Patterns
Mediator Design Pattern
Chapter 5:Design Patterns
Introduction to Design Patterns
Facade Pattern Jim Fawcett CSE776 – Design Patterns Summer 2010
Mediator Design Pattern (Behavioral)
GRASP (General Responsibility Assignment Software Patterns)
Mediator.
Object Oriented Design Patterns - Structural Patterns
Informatics 122 Software Design II
Presentation transcript:

A Behavior Object Pattern The Mediator Pattern A Behavior Object Pattern

Battling Class Complexity Consider an air traffic controller Many planes circle an airport If they communicated with each other the skies above an airport would be a chaos Accepted solution: have the planes communicate directly with an air traffic controller tower for permission to land The planes do not even have to know about each other This information is kept with the tower

Battling Class Complexity Let’s abstract this to classes and their objects in a program When class objects are allowed to communicate directly with each other then they become too tightly coupled When one object wishes to send a message to another then we need the equivalent of an air traffic controller to forward the message to the recipient Keep the dispatching information inside the new controller Call this coordinating object a mediator

AirController Airplane +mediator Boeing 747 Yerevan Int’l Cessna

Remarks Airplane is an abstract class for the concrete planes that fly AirController is an interface to concrete mediators Cessna and Boeing747 are the objects controlled by the mediator, called colleagues Yerevan International is the concrete mediator that coordinates the colleague objects

Most Importantly The Colleagues do not send messages to each other They send messages to the mediator The mediator sends messages to the recipient Each plane knows about the concrete controller Whenever something is to be communicated it goes to the AirController

The Mediator Pattern Mediator Colleague Concrete Coll 2 Concrete Med

Object View (run-time) aConcreteMediator aColleague aColleague mediator mediator aColleague aColleague mediator mediator

Mediator Encapsulates interconnects between objects Is the communications hub Is responsible for coordinating and conrolling colleague interaction Promotes loose coupling between classes By preventing from referring to each other explicitly Arbitrates the message traffic

How to Use Mediator Identify a collection of interacting objects whose interaction needs simplification Get a new abstract class that encapsulates that interaction Create a instance of that class and redo the interaction with that class alone But, don’t play God!

When to Use Mediator When a set of objects communicates in a well-defined, but complex way When reusing an object is difficult because it refers to and communicates with many other objects (tight coupling) When a behavior that is distributed between several classes should be customizable without a lot of subclassing

Related Patterns Observer--communication distributed by using observer and subject objects Mediator encapsulates the communication Facade--Create a class interface for an entire subsystem The subsystem doesn’t know about the Facade Facade doesn’t add functionality, Mediator does Mediator’s colleagues are aware of Mediator

The Facade Pattern Purpose: Create a class that is the interface to an entire subsystem whose diverse methods should remain within the system Consequences Hide the implementation of the subsystem from clients Promote weak coupling between the subsystem and the clients Does not prevent clients from using subsystem classes--should it?

Facade Pattern client client Facade Subsystem

Project Use Add a GUI to POST Decouple the GUI from the business logic Make the business logic totally unaware of the graphical interface--make it get called by the mediator, never directly from the GUI component

Example Business Logic Mediator GUI Payment Panel MakePayment() payment = new... makePayment() Complete this diagram for all GUI components!