Proxy, Observer, Symbolic Links Rebecca Chernoff.

Slides:



Advertisements
Similar presentations
Design Patterns.
Advertisements

 Recent researches show that predicative programming can be used to specify OO concepts including classes, objects, interfaces, methods, single and multiple.
Observer Method 1. References Gamma Erich, Helm Richard, “Design Patterns: Elements of Reusable Object- Oriented Software” 2.
Figures – Chapter 7.
Design Patterns Pepper. Find Patterns Gang of Four created 23 Siemens published another good set x
C15: Design Patterns Gamma,Helm,Johnson,Vlissides (GOF)
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.
Reza Gorgan Mohammadi AmirKabir University of Technology, Department of Computer Engineering & Information Technology Advanced design.
Observer Pattern Fall 2005 OOPD John Anthony. What is a Pattern? “Each pattern describes a problem which occurs over and over again in our environment,
Observer Pattern Tu Nguyen. General Purpose When one object changes state, all the dependent objects are notified and updated. Allows for consistency.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition File-System Interface.
BehavioralCmpE196G1 Behavioral Patterns Chain of Responsibility (requests through a chain of candidates) Command (encapsulates a request) Interpreter (grammar.
Copyright © Active Frameworks Inc. - All Rights Reserved.More On Behavioral Patterns - Page L9-1 PS95&96-MEF-L16-1 Dr. M.E. Fayad Creationa l.
Design Patterns Part IV (TIC++V2:C10) Yingcai Xiao 10/01/08.
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.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. The Proxy Design Pattern (1) –A structural design pattern.
Proxy Design Pattern Source: Design Patterns – Elements of Reusable Object- Oriented Software; Gamma, et. al.
Client/Server Software Architectures Yonglei Tao.
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.
Design Patterns.
Smart Reference Proxy Provides additional actions whenever an object is referenced (e.g., counting the number of references to the object) Firewall Proxy.
02 - Behavioral Design Patterns – 2 Moshe Fresko Bar-Ilan University תשס"ח 2008.
1 The Proxy Design Pattern Problem: Defer the cost of object creation and init. until actually used Applicability (possible contexts): – Virtual Proxy:
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
Design Patterns Part two. Structural Patterns Concerned with how classes and objects are composed to form larger structures Concerned with how classes.
Observer Behavioral Pattern. Intent Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified.
Programming in C# Observer Design Pattern
Chapter 10: File-System Interface Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Jan 1, 2005 Chapter 10: File-System.
In the name of Allah The Proxy Pattern Elham moazzen.
Behavioral Pattern: Observer C h a p t e r 5 – P a g e 186 A large monolithic design does not scale well as additional graphical and monitoring requirements.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns VII Observer, Command, and Memento.
Design Patterns CSCI 5801: Software Engineering. Design Patterns.
Structural Design Patterns
Where Do Surrogates Fit into This Proxy Pattern Observer Pattern Visitor Pattern By Kurt Rehwinkel.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns V More Structural Patterns.
02 - Structural Design Patterns – 2 Moshe Fresko Bar-Ilan University תשס"ח 2008.
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.
Proxy.
Proxy Design Pattern By:Diksha Agarwal.
Copyright © Active Frameworks Inc. - All Rights Reserved - V2.0Design Pattern Catalog - Page L3-1 PS95&96-MEF-L10-1 Dr. M.E. Fayad Creationa.
Design Pattern. Definition: A design pattern is a general reusable solution to a commonly occurring problem within a given context in software design.
OBSERVER DESIGN PATTERN. Behavioral Patterns  Behavioral patterns are those patterns that are most specifically concerned with communication between.
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
BEHAVIORAL PATTERNS 13-Sep-2012 Presenters Sanjeeb Kumar Nanda & Shankar Gogada.
1 Advanced Object-oriented Design – Principles and Patterns Structural Design Patterns.
CS 210 Proxy Pattern Nov 16 th, RMI – A quick review A simple, easy to understand tutorial is located here:
Chapter 8 Object Design Reuse and Patterns. More Patterns Abstract Factory: Provide manufacturer independence Builder: Hide a complex creation process.
The Observer Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
The Proxy Pattern (Structural) ©SoftMoore ConsultingSlide 1.
CSE 332: Design Patterns (Part II) Last Time: Part I, Familiar Design Patterns We’ve looked at patterns related to course material –Singleton: share a.
OBSERVER PATTERN OBSERVER PATTERN Presented By Presented By Ajeet Tripathi ISE
The Observer Design Pattern Author :Erich Gamma, et al. Source :Elements of Reusable Object-Oriented Software Speaker : Chiao-Ping Chang Advisor : Ku-Yaw.
Week 9, Day 1 Proxy SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors: Dr. Yoder 1.
Software Design and Architecture Muhammad Nasir Structural Design Patterns
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
February 23, 2009Observer Pattern, OOA&D, Rubal Gupta, CSPP, Winter ‘09 Observer Pattern Defines a “one-to-many” dependency between objects so that when.
Chapter 10 Design Patterns.
Factory Patterns 1.
Observer Design Pattern
Design Patterns with C# (and Food!)
Informatics 122 Software Design II
Observer Pattern 1.
Structural Patterns: Adapter and Bridge
Informatics 122 Software Design II
Presentation transcript:

Proxy, Observer, Symbolic Links Rebecca Chernoff

Proxy Pattern Intent – Provide a surrogate or placeholder for another object to control access to it Other Names – Surrogate

Proxy: Motivations & Applicability Local representative of object in a different address space. Defer cost of creation and initialization. Protection via access control. Reference counting Load a persistent object into memory when first referenced Object locking Remote Proxy Virtual Proxy Protection Proxy Smart Reference

Proxy: Participants RealSubject – Defines the real object that the proxy represents. Subject – Defines the common interface for RealSubject and Proxy. – Allows for a Proxy to be used wherever a RealSubject is expected.

Proxy: Participants Proxy – Maintains a reference to the real subject. May refer to a Subject if the RealSubject and Subject interfaces are the same. – Identical interface to Subject so the Proxy can be substituted. – Controls access to the real subject. – May be responsible for creating and deleting the real subject.

Proxy: Participants Additional Responsibilities of Proxy – Remote Proxy Encode and send the request to the real subject in a different address space. – Virtual Proxy Cache additional information in order to postpone accessing the real subject. – Protection Proxy Check access permissions.

Proxy: Structure

Proxy: Consequences Introduces a level of indirection – Remote Proxy Hides fact that object resides in a different address space. – Virtual Proxy Perform optimizations such as creation on demand. – Protection Proxy and Smart References Allow additional housekeeping tasks when object is accessed. Copy-On-Write

Proxy: Related Patterns Adapter – Provides a different interface to an object, but since Proxy can refuse to perform a request, the interface is effectively a subset. Decorator – Similar implementation to proxy, but different purpose. Decorator adds responsibilities whereas proxy controls access.

Observer Pattern Intent – Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically Also Known As – Dependents – Publish-Subscribe

Observer: Motivation Maintain consistency between related objects. – Application Data vs. Presentation Avoid tightly coupled classes that reduce reusability.

Observer: Applicability An abstraction has two aspects, one dependent on the other. A change to one object requires changing others. An object should be able to notify other objects without making assumptions about the objects.

Observer: Participants Observer – Defines an interface for objects to be notified when a subject changes. Subject – Defines an interface for attaching and detaching Observer objects. – Unknown number of Observer objects.

Observer: Participants ConcreteObserver – Implements the Observer interface to keep its state consistent with the subject’s. – Maintains a reference to the ConcreteSubject – Stores state that should stay consistent with the subject’s. ConcreteSubject – Implements the Subject interface to update Observers. – Stores state of interest to ConcreteObserver objects. – Sends a notification to its observers when its state changes.

Observer: Structure

Observer: Collaborations

Observer: Consequences Vary subjects and observers independently. Abstract coupling between Subject and Observer. Support for broadcast communication. Simple update to Server may cause a cascade of updates to Observer and its dependent objects.

Observer: Implementation Mapping subjects to their observers. – Tradeoff between time and space. Observing more than one subject. – Observer needs to know which Subject is notifying. Who triggers the update? – Subject: client doesn’t have to remember to update, but consecutive operations cause multiple updates. – Observer: client can wait to trigger the update, but client must remember to call update. Dangling references to deleted subjects. – Notify observers right before deletion. Observers of multiple Subjects can’t be deleted when just one Subject is deleted.

Observer: Implementation Making sure the Subject state is self-consistent before notification. – Use TemplateMethod pattern with Notify as last operation. Avoiding observer-specific update protocols: the push and pull models. – Push Model: Detailed information sent regardless. – Pull Model: Observers ask for details explicitly. Specifying modifications of interest explicitly. – Observers register for a specific aspect of interest.

Observer: Implementation Encapsulating complex update semantics. – Change-Manager Takes responsibility of maintaining references to observers away from the Subject. Defines a particular update strategy. Updates all dependent observers at the request of a subject. Combining the Subject and Observer classes. – When multiple inheritance not supported by language, both interfaces may reside in one class.

Observer Related Patterns – Mediator The ChangeManager encapsulates complex update semantics, thus acting as a mediator between the Subject and its Observers. – Singleton ChangeManager may be unique and globally accessible.

But Where Do Surrogates Fit into This? File System Example Symbolic Links / Aliases / Shortcuts – Reference to another node in the file system. – Surrogate for a node, not the node itself. – Own access rights. – Edit and save a file. – Add and remove nodes to a directory.

But Where Do Surrogates Fit into This? How do I find the right design pattern for the task? – Consider how design patterns solve design problems. – Scan the Intent sections for something that sounds right. – Study how patterns interrelate. – Look at patterns whose purpose corresponds to what you’re trying to do. – Examine a relevant cause of redesign and apply the patterns that help you avoid it. – Consider what should be variable in your design.

But Where Do Surrogates Fit into This? Proxy Pattern – Subject => Node – Proxy => Link – Real Subject => ?

But Where Do Surrogates Fit Into This?