Mediator Matt G. Ellis. Overview ► Intent ► Motivation ► Mediators in GUI applications ► Mediators and Relational Integrity ► Conclusion ► Questions.

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

Unit 7 Generic Interfaces and Encapsulation, a Class in the Middle Kirk Scott.
The Bridge Pattern.. Intent Decouple an abstraction from its implementation so that the two can vary independently Also known as: Handle/Body.
Design Pattern: Mediator Mediator Modified from Kyle Kimport’s: Design Patterns: Mediator Design Patterns: Mediator Ref:
Component Patterns – Architecture and Applications with EJB copyright © 2001, MATHEMA AG Component Patterns Architecture and Applications with EJB JavaForum.
Patterns – Day 9 Façade Composite Reminders: Faculty candidate talk Friday 4:20 PM O-267. Brian Postow: Games and Complexity Theory Another talk on Monday!
R-Mancala Srinivas Krishnan & Kiranjit Sidhu. Outline Design Details Refactoring Experience Demo.
Iterator Matt G. Ellis. Intent Metsker: Provide a way to access elements of a collection sequentially. GoF: Provide a way to access the elements of an.
Factory Method Joey Richey Kevin Gorski. Definition Allows a class developer define the interface for creating an object while retaining control of which.
Visitor Matt G. Ellis. Intent Metsker: Let developers define a new operation for a hierarchy without changing the hierarchy classes. GoF: Represent an.
Mediator A Behavioral Design Pattern for the New Millennium Cory Nugent.
Software Engineering I Object-Oriented Design Software Design Refinement Using Design Patterns Instructor: Dr. Hany H. Ammar Dept. of Computer Science.
The Composite Pattern.. Composite Pattern Intent –Compose objects into tree structures to represent part-whole hierarchies. –Composite lets clients treat.
Client/Server Software Architectures Yonglei Tao.
UNIT-V The MVC architecture and Struts Framework.
Creational Patterns Making Objects The Smart Way Brent Ramerth Abstract Factory, Builder.
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.
Design Patterns in Java Chapter 18 Prototype Summary prepared by Kirk Scott 1.
Chapter 7 Designing Classes. Class Design When we are developing a piece of software, we want to design the software We don’t want to just sit down and.
SOA, BPM, BPEL, jBPM.
MVC pattern and implementation in java
A Behavior Object Pattern
Mobile search engine for a smart phone / navigation system can be used to search and compare hundreds of stores and their products in seconds. © 2001 –
Software Design Refinement Using Design Patterns Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
Database refactoring. For the beginning… Avoid overspecialization Application developerDatabase developer Developer Communication Cooperation Exchange.
Design Patterns in Java Chapter 13 Flyweight Summary prepared by Kirk Scott 1.
Emeka Egbuonye CSPP March 02,2010 The Mediator Pattern.
Case Studies on Design Patterns Design Refinements Examples.
CS 350 – Software Design The Object Paradigm – Chapter 1 If you were tasked to write code to access a description of shapes that were stored in a database.
Creational Patterns (1) CS350, SE310, Fall, 2010.
Architecture styles Pipes and filters Object-oriented design Implicit invocation Layering Repositories.
Design Patterns Part two. Structural Patterns Concerned with how classes and objects are composed to form larger structures Concerned with how classes.
Design Patterns in Java Chapter 10 Mediator Summary prepared by Kirk Scott 1.
Object Oriented Analysis and Design 1 Chapter 7 Database Design  UML Specification for Data Modeling  The Relational Data Model and Object Model  Persistence.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns IX Interpreter, Mediator, Template Method recap.
Chapter 10 Analysis and Design Discipline. 2 Purpose The purpose is to translate the requirements into a specification that describes how to implement.
Architectural Patterns Support Lecture. Software Architecture l Architecture is OVERLOADED System architecture Application architecture l Architecture.
Java Data Types Assignment and Simple Arithmetic.
Recap form last time How to do for loops map, filter, reduce Next up: dictionaries.
Enterprise Integration Patterns CS3300 Fall 2015.
Games Development 2 Overview & Entity IDs and Communication CO3301 Week 1.
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.
Behavioral Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
CS616: Software Engineering Spring 2009 Design Patterns Sami Taha.
Manali Joshi1 The Observer Design Pattern Presented By: Manali Joshi.
Rational Agency CSMC Introduction to Artificial Intelligence January 8, 2004.
The Mediator Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
1 Copyright © 2004, Oracle. All rights reserved. Oracle Application Development Framework.
The Facade Pattern (Structural) ©SoftMoore ConsultingSlide 1.
Component Patterns – Architecture and Applications with EJB copyright © 2001, MATHEMA AG Component Patterns Architecture and Applications with EJB Markus.
Watching the movie the hard way…. Page 256 – Head First Design Patterns.
1 COS 260 DAY 12 Tony Gauvin. 2 Agenda Questions? 5 th Mini quiz –Chapter 5 40 min Assignment 3 Due Assignment 4 will be posted later (next week) –If.
CS 350 – Software Design The Adapter Pattern – Chapter 7 Gang of Four Definition: Convert the interface of a class into another interface that the client.
From Use Cases to Implementation 1. Structural and Behavioral Aspects of Collaborations  Two aspects of Collaborations Structural – specifies the static.
From Use Cases to Implementation 1. Mapping Requirements Directly to Design and Code  For many, if not most, of our requirements it is relatively easy.
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University A Metric-based Approach for Reconstructing Methods.
Mediator Design Pattern
Observer Design Pattern
Anatomy of a Class & Method
Doug Jeffries CS490 Design Patterns May 1, 2003
Objects First with Java A Practical Introduction using BlueJ
Objects First with Java
Mediator Design Pattern (Behavioral)
CSCI1600: Embedded and Real Time Software
Objects First with Java A Practical Introduction using BlueJ
Developing and testing enterprise Java applications
Objects First with Java A Practical Introduction using BlueJ
Dependency Inversion principle
Presentation transcript:

Mediator Matt G. Ellis

Overview ► Intent ► Motivation ► Mediators in GUI applications ► Mediators and Relational Integrity ► Conclusion ► Questions

Intent ► Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you very their interaction independently

Motivation ► Object Oriented design encourages distribution of behavior among objects ► However, Good design is thwarted by every object referencing every other object ► Changing systems behavior becomes difficult ► Helps to prevent classes from becoming “thick”

Mediator versus Façade ► Façade pattern help refractor FlightPanel from Oozinoz ► Refactoring can only go so far, complex applications still might need complex code even after applying Façade pattern

Mediators at Oozinoz ► Chemicals for fireworks kept in tubs ► Robots move most of the tubs from machine to machine ► However, humans can override the system

FlightPanel_1 ► Many methods exist to lazy-initialize variables ► Rest control event handling logic

Challenge 1 ► Refactor PlaceATub_1 into two classes, introducing a new PlaceATubMediator that receives the events of the GUI

Challenge 1 ► Refactor PlaceATub_1 into two classes, introducing a new PlaceATubMediator that receives the events of the GUI

Relational Integrity ► If Object A points to Object B then… ► Object B points to Object A ► A more rigorous definition can be found in Metsker, page 108

Relational Integrity and Java ► Two Major Problems  Objects forget previous values  No built in support for Relational Integrity TubMachine T305StarPress-2402 T308StarPress-2402 T377ShellAssembler-2301 T379ShellAssembler-2301 T389ShellAssembler-2301 T001Fuser-2102 T002Fuser-2102

ModelTubMachineT305StarPress-2402 T308StarPress-2402 T377ShellAssembler-2301 T379ShellAssembler-2301 T389ShellAssembler-2301 T001Fuser-2102 T002Fuser-2102

Challenge 2 ► Suppose we have this code: //tell tub about machine, and machine about tub t.setMachine(m);m.addTub(t); ► What happens when t is tub T308 and m is Fuser-2101?

Challenge 2

► Really Bad Things… ► Two machines think they have tub T308 in them ► This can’t happen in the real world, why should it happen at Oozinoz? ► Mediators can help

Mediators for Relational Integrity ► Pull all relational information into a mediator outside both classes ► Have both tubs and machines have a reference to this mediator ► Use a Map to store these key/value pairs

Mediators for Relational Integrity ► getMachine is simple, since t is the key of the map, HashMap makes it easy to get the value.

Mediators for Relational Integrity ► Somewhat more complex, but the intent is the same.

Mediators for Relational Integrity ► The most trivial method of all. Relational Integrity is maintained by the internal structure of the Map

Challenge 3 ► Write the code for the Tub methods: getMachine() and setMachine()

Conclusions ► Mediators provide loose coupling creating a “pluggable” system  Changing a mediator can change how applications deal with events ► Mediators often found in GUIs  Swing’s event framework nudges the use of mediators, but they can be in the same class ► Mediators also help to provide relational integrity between objects

Questions