Flyweight Pattern 1.

Slides:



Advertisements
Similar presentations
GoF State Pattern Aaron Jacobs State(305) Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.
Advertisements

Structural Pattern: Flyweight To maximize flexibility, it is often advantageous to model objects down to very fine levels of granularity. C h a p t e.
Matt Klein. Decorator Pattern  Intent  Attach Additional responsibilities to an object by dynamically. Decorators provide a flexible alternative to.
AP 04/02 Structural Patterns Describe how classes and objects are composed to form larger structures Structural class patterns use inheritance to compose.
Flyweight: Structural Pattern Prepared by Galina Walters.
C15: Design Patterns Gamma,Helm,Johnson,Vlissides (GOF)
Computer Science 313 – Advanced Programming Topics.
SWE 4743 Strategy Patterns Richard Gesick. CSE Strategy Pattern the strategy pattern (also known as the policy pattern) is a software design.
Matt Klein 7/6/2009.  Behavioral Pattern  Intent  Allow an object to alter its behavior when its internal state changes. The object will appear to.
Imagine that you need to create a system to represent all of the cars in a city. You need to store the details about each car ( model, and year) and the.
Flyweight An Object Structural Design Pattern JM Imbrescia.
Prototype Pattern Creational Pattern Specify the kinds of objects to create using a prototypical instance, and create new objects by copy this prototype.
The Flyweight Pattern Nik Reiman Joshua Hertz. Roadmap What is the Flyweight Pattern? UML When is Flyweight Useful? How to Use the Flyweight Pattern?
Fall 2009ACS Ron McFadyen1 The context maintains an instance of a concrete state subclass State Pattern Each subclass (concrete state) implements.
Collaboration Diagrams. Example Building Collaboration Diagrams.
Design Patterns I 1. Creational Pattern Singleton: intent and structure Ensure a class has one instance, and provide a global point of access to it 2.
Algorithm Programming Structural Design Patterns Bar-Ilan University תשס " ו by Moshe Fresko.
The Composite Pattern.. Composite Pattern Intent –Compose objects into tree structures to represent part-whole hierarchies. –Composite lets clients treat.
Interpreter By: Mahmoodreza Jahanseir Amirkabir University of Technology Computer Engineering Department Fall 2010.
Katie C. O’Shea Dennis T. Tillman 11 February 2K2 Flyweight.
BY VEDASHREE GOVINDA GOWDA
Linzhang Wang Dept. of Computer Sci&Tech, Nanjing University The Composit Pattern.
Design Patterns.
Design patterns. What is a design pattern? Christopher Alexander: «The pattern describes a problem which again and again occurs in the work, as well as.
1 GoF Template Method (pp ) GoF Strategy (pp ) PH Single User Protection (pp ) Presentation by Julie Betlach 6/08/2009.
Design Pattern Interpreter By Swathi Polusani. What is an Interpreter? The Interpreter pattern describes how to define a grammar for simple languages,
Strategy Design Patterns CS 590L - Sushil Puradkar.
18 April 2005CSci 210 Spring Design Patterns 1 CSci 210.
Computing IV Singleton Pattern Xinwen Fu.
GoF: Document Editor Example Rebecca Miller-Webster.
Structural Design Patterns
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.
Team 6 “The Unparseables” Design Patterns Chain of Responsibility Observer Flyweight 1.
Title Carolina First Steering Committee October 9, 2010 Online Voting System Design Yinpeng Li and Tian Cao May 3, 2011.
Prototype pattern Participants Prototype (Graphic) – declared an interface for cloning itself ConcretePrototype (EditBox, Slider) – implements an operation.
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.
Linzhang Wang Dept. of Computer Sci&Tech, Nanjing University The Strategy Pattern.
DESIGN PATTERNS COMMONLY USED PATTERNS What is a design pattern ? Defining certain rules to tackle a particular kind of problem in software development.
Design Patterns By Mareck Kortylevitch and Piotreck Ratchinsky.
The Strategy Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
Decorator Design Pattern Phillip Shin. Overview Problem Solution Example Key points.
The Flyweight Pattern (Structural) ©SoftMoore ConsultingSlide 1.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
The State Design Pattern A behavioral design pattern. Shivraj Persaud
COMPOSITE PATTERN NOTES. The Composite pattern l Intent Compose objects into tree structures to represent whole-part hierarchies. Composite lets clients.
David Evans CS201J: Engineering Software University of Virginia Computer Science Lecture 5: Implementing Data Abstractions.
Command Pattern. Intent encapsulate a request as an object  can parameterize clients with different requests, queue or log requests, support undoable.
Strategy Design Pattern
Strategy Pattern Jim Fawcett CSE776 – Design Patterns Fall 2014.
Structural Patterns Structural patterns control the relationships between large portions of your applications. Structural patterns affect applications.
Introduction to Design Patterns
Software Design and Architecture
Flyweight Design Pattern
Design Patterns with C# (and Food!)
Object Pool Pattern 1.
More Design Patterns 1.
More Design Patterns 1.
Decorator Intent Also known as Wrapper Example: a Text Window
Design Patterns in Game Design
Jim Fawcett CSE776 – Design Patterns Summer 2003
State Design Pattern 1.
Adapter Pattern 1.
Observer Pattern 1.
Prototype Pattern 1.
Ms Munawar Khatoon IV Year I Sem Computer Science Engineering
BRIDGE PATTERN.
Software Design Lecture : 39.
Strategy Pattern Jim Fawcett CSE776 – Design Patterns Fall 2014.
Presentation transcript:

Flyweight Pattern 1

Definition Use sharing to support large numbers of fine-grained objects efficiently

Class Diagram FlyweightFactory <interface> Flyweight flyweights GetFlyweight(key) Operation() if flyweights[key] exists return existing flyweight else create new flyweight add to pool of flyweights return newest flyweight Client ConcreteFlyweight ConcreteFlyweight Operation() Operation()

Participants Flyweight ConcreteFlyweight UnsharedConcreteFlyweight declares an interface through which flyweights can receive and act on extrinsic state. ConcreteFlyweight  implements the Flyweight interface and adds storage for intrinsic state, if any. A ConcreteFlyweight object must be sharable. Any state it stores must be intrinsic, that is, it must be independent of the ConcreteFlyweight object's context. UnsharedConcreteFlyweight  not all Flyweight subclasses need to be shared. The Flyweight interface enables sharing, but it doesn't enforce it. It is common for UnsharedConcreteFlyweight objects to have ConcreteFlyweight objects as children at some level in the flyweight object structure. FlyweightFactory  creates and manages flyweight objects ensures that flyweights are shared properly. When a client requests a flyweight, the FlyweightFactory objects assets an existing instance or creates one, if none exists. Client  maintains a reference to flyweight(s). computes or stores the extrinsic state of flyweight(s)

?

References Dofactory – “Flyweight” http://www.dofactory.com/net/flyweight-design-pattern