Mediator Pattern and Multiuser Protection Billy Bennett June 8 th, 2009.

Slides:



Advertisements
Similar presentations
Welcome to. Who am I? A better way to code Design Patterns ???  What are design patterns?  How many are there?  How do I use them?  When do I use.
Advertisements

Creational Patterns, Abstract Factory, Builder Billy Bennett June 11, 2009.
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.
Amirkabir University of Technology, Computer Engineering Faculty, Intelligent Systems Laboratory 1 Mediator Abbas Rasoolzadegan.
Design Pattern: Mediator Mediator Modified from Kyle Kimport’s: Design Patterns: Mediator Design Patterns: Mediator Ref:
DESIGN PATTERNS OZGUR RAHMI DONMEZ.
Lecture 13 UML diagrams state-chart diagrams Design Pattern.
A Behavioral Pattern. Problem: Simple enough right? Object.
BehavioralCmpE196G1 Behavioral Patterns Chain of Responsibility (requests through a chain of candidates) Command (encapsulates a request) Interpreter (grammar.
IEG3080 Tutorial 7 Prepared by Ryan.
Design Patterns CS is not simply about programming
Design Patterns. What are design patterns? A general reusable solution to a commonly occurring problem. A description or template for how to solve a problem.
Cam Quach Joel Derstine Mediator: Object Behavioral.
OOMPA Lecture 10 Design Patterns Singleton Factory Method
Design Patterns Module Name - Object Oriented Modeling By Archana Munnangi S R Kumar Utkarsh Batwal ( ) ( ) ( )
ECE 355 Design Patterns Tutorial Part 2 (based on slides by Ali Razavi) Presented by Igor Ivković
PRESENTED BY SANGEETA MEHTA EECS810 UNIVERSITY OF KANSAS OCTOBER 2008 Design Patterns.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns VI Composite, Iterator, and Visitor Patterns.
Design Patterns academy.zariba.com 1. Lecture Content 1.What are Design Patterns? 2.Creational 3.Structural 4.Behavioral 5.Architectural 6.Design Patterns.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
BDP Behavioral Pattern. BDP-2 Behavioral Patters Concerned with algorithms & assignment of responsibilities Patterns of Communication between Objects.
Design Patterns.
A Behavior Object Pattern
Design Patterns CSCI 5801: Software Engineering. Design Patterns.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns IX Interpreter, Mediator, Template Method recap.
L11-12: Design Patterns Definition Iterator (L4: Inheritance)‏ Factory (L4: Inheritance)‏ Strategy (L5: Multiple Inheritance)‏ Composite (L6: Implementation.
Software Design Patterns (1) Introduction. patterns do … & do not … Patterns do... provide common vocabulary provide “shorthand” for effectively communicating.
Object Oriented Software Engineering Chapter 16 and 17 review 2014/06/03.
Design Patterns CS 124 Reference: Gamma et al (“Gang-of-4”), Design Patterns.
Unit 4 Object-Oriented Design Patterns NameStudent Number CAI XIANGHT082182A KYAW THU LINHT082238Y LI PENGFEIHT082220L NAUNG NAUNG LATTHT082195L PLATHOTTAM.
Structural Design Patterns
Design Patterns CSIS 3701: Advanced Object Oriented Programming.
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.
Design Pattern Dr. Zhen Jiang West Chester University url:
Creational Patterns
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.
Linzhang Wang Dept. of Computer Sci&Tech, Nanjing University The Strategy Pattern.
Proxy.
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.
Software Design Patterns Curtsy: Fahad Hassan (TxLabs)
Billy Bennett June 22,  Intent Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype.
Behavioral Patterns1 Nour El Kadri SEG 3202 Software Design and Architecture Notes based on U of T Design Patterns class.
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
Design Patterns Introduction
Design Patterns SE464 Derek Rayside images from NetObjectives.com & Wikipedia.
1 Chapter 5:Design Patterns. 2 What are design pattern?  Schematic description of design solution to recurring problems in software design and,  Reusable.
The Mediator Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
The Facade Pattern (Structural) ©SoftMoore ConsultingSlide 1.
Proxy Pattern defined The Proxy Pattern provides a surrogate or placeholder for another object to control access to it by creating a representative object.
CS 210 Proxy Pattern Nov 16 th, RMI – A quick review A simple, easy to understand tutorial is located here:
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.
Design Patterns Creational Patterns. Abstract the instantiation process Help make the system independent of how its objects are created, composed and.
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
Mediator Design Pattern
Abstract Factory Pattern
Chapter 5:Design Patterns
MPCS – Advanced java Programming
Introduction to Design Patterns
Design Patterns with C# (and Food!)
object oriented Principles of software design
Abstract Factory Pattern
Intent (Thanks to Jim Fawcett for the slides)
Presented by Igor Ivković
Multiuser Protection and the Mediator Pattern
Software Engineering Lecture 7 - Design Patterns
Mediator Design Pattern (Behavioral)
Informatics 122 Software Design II
Presented by Igor Ivković
Presentation transcript:

Mediator Pattern and Multiuser Protection Billy Bennett June 8 th, 2009

Mediator

Applicability A set of objects communicates in well-defined, but complex ways. Often with unstructured dependencies. Reusing objects is difficult because it refers to and communicates with many other objects. A behavior that’s distributed between several classes should be customizable without a lot of subclassing.

Participants Mediator ConcreteMediator Colleague ConcreteColleague

Structure

Consequences Limits subclassing ▫Localizes behavior that would be otherwise distributed among many objects ▫Changes in behavior require changing only the Mediator class

Consequences Decouples colleagues ▫Colleagues become more reusable. ▫You can have multiple types of interactions between colleagues, and you don’t need to subclass or otherwise change the colleague class to do that.

Consequences Simplifies object protocols ▫Many-to-many interactions replaced with one-to- many interactions ▫More intuitive ▫More extensible ▫Easier to maintain

Consequences Abstracts object cooperation ▫Mediation becomes an object itself ▫Interaction and individual behaviors are separate concepts that are encapsulated in separate objects

Consequences Centralizes control ▫Mediator can become very complex ▫With more complex interactions, extensibility and maintenance may become more difficult

Sample Code class DialogDirector { public: virtual ~DialogDirector (); virtual void ShowDialog (); virtual void WidgetChanged (Widget*) = 0; protected: DialogDirector (); virtual void CreateWidgets () = 0; }; class Widget { public: Widget (DialogDirector*); virtual void Changed (); virtual void HandleMouse (MouseEvent& event); //... private: DialogDirector* _director; }; Void Widget::Changed () { _director->WidgetChanged(this); }

Implementation Issues Omitting the abstract Mediator class – possible when only one mediator exists Strategies for Colleague-Mediator communication ▫Observer class ▫Pointer / other identifier to “self” passed from colleague to mediator, who pass it to the other colleague(s)

Related Patterns Façade ▫Unidirectional rather than cooperative interactions between object and subsystem Observer ▫May be used as a means of communication between Colleagues and the Mediator

Other thoughts Which strategy (or alternative pattern) should we use when the Mediator becomes too monolithic?

Multiuser Protection

Example from UNIX Each node in the file system has a “user” Everyone else is “other” Different actions can be assigned to “user” or to “user and other” (read, write, etc.) User defined by a unique login / password

Concrete Need security Use encapsulation Data should be inaccessible to the client Actually everything must be inaccessible to the client

Which Pattern? We’re creating an object, so probably a creational pattern Abstract factory? ▫No – we don’t need families of objects and we’re fine creating an abstract class Builder? ▫No – not an overly complex object Factory method? ▫No – similar to Abstract Factory

Which Pattern? Prototype? ▫No – addresses what, not how Singleton? ▫Ahhhhhhh – pattern designed to return a single instance of an object. ▫NOTE: Here, we’re not worried about one instance of object total, but rather per user ▫So, we can just change Instance (); static const User* User::logIn ( const string& loginName, const string& password);

Next Problem What about groups (a la UNIX)? Composite? ▫No – groups are not actually a hierarchy (no groups of groups and users may belong > 1 group) Mediator? ▫Yes – good for centralizing, objects don’t need to know about each other (no wasted resources), good security

Wrapping Up

Visitor ConcreteVisitor Composite:Component Proxy: Subject TemplateMethod:AbstractClass Visitor:Element Leaf Proxy TemplateMethod:ConcreteClass Leaf Proxy:RealSubject TemplateMethod:ConcreteClass Composite Proxy:RealSubject TemplateMethod:ConcreteClass Mediator:ConcreteColleague Singleton (variant) ConcreteMediator Singleton Mediator:ConcreteColleague