Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 210 Proxy Pattern Nov 16 th, 2006. RMI – A quick review A simple, easy to understand tutorial is located here:

Similar presentations


Presentation on theme: "CS 210 Proxy Pattern Nov 16 th, 2006. RMI – A quick review A simple, easy to understand tutorial is located here:"— Presentation transcript:

1 CS 210 Proxy Pattern Nov 16 th, 2006

2 RMI – A quick review A simple, easy to understand tutorial is located here: http://www.comp.hkbu.edu.hk/~jng/comp 3320/rmi.html http://www.comp.hkbu.edu.hk/~jng/comp 3320/rmi.html

3 Proxy Pattern defined The Proxy Pattern provides a surrogate or placeholder for another object to control access to it. The proxy pattern is used to create a representative object that controls access to another object, which may be remote, expensive to create or in need of securing.

4 Proxy Class Diagram

5

6 Making the call

7

8 Remote Proxy

9 Virtual Proxy

10 Playing CD Covers

11 Playing CD Cover Proxy

12 ImageProxy process

13 Virtual Proxy Look at Eclipse code

14 ImageProxy process

15

16 Using Java API’s Proxy to create a protection proxy > Subject request() > InvocationHandler invoke() RealSubject request() Proxy request() InvocationHandler invoke()

17 Matchmaking example See Eclipse code

18 Summary so far.. OO Basics Abstraction Encapsulation Inheritance Polymorphism OO Principles Encapsulate what varies Favor composition over inheritance Program to interfaces not to implementations Strive for loosely coupled designs between objects that interact Classes should be open for extension but closed for modification. Depend on abstracts. Do not depend on concrete classes. Only talk to your friends Don’t call us, we will call you A class should have only one reason to change.

19 Summary so far… OO Patterns Strategy Pattern defines a family of algorithms, Encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it. Observer Pattern defines a one-to-many dependency between objects so that when one object changes state, all of its dependents are notified and updated automatically. Decorator Pattern – attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative for sub-classing for extending functionality Abstractor Factory – Provide an interface for creating families of related or dependent objects without specifying their concrete classes. Factory Method – Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory method lets a class defer instantiation to the subclasses.

20 OO Patterns - Continued Command Pattern – Encapsulates a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations. The Adapter Pattern converts the interface of a class into another interface the clients expect. Adapter lets classes work together that couldn’t otherwise because of incompatible interfaces. The Façade Pattern provides a unified interface to a set of interfaces in a subsystem. Façade defines a higher level interface that makes the subsystem easier to use. Template Method defines the skeleton of an algorithm in a method, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm’s structure. Iterator - provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation. The Composite Pattern allows you to compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly. The State Pattern allows an object to alter its behavior when its internal state changes. The object will appear to change its class. The Proxy Pattern provides a surrogate or placeholder for another object to control access to it.


Download ppt "CS 210 Proxy Pattern Nov 16 th, 2006. RMI – A quick review A simple, easy to understand tutorial is located here:"

Similar presentations


Ads by Google