Katie C. O’Shea Dennis T. Tillman 11 February 2K2 Flyweight.

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

Matt Klein. Decorator Pattern  Intent  Attach Additional responsibilities to an object by dynamically. Decorators provide a flexible alternative to.
18-1 Verifying Object Behavior and Collaboration Role playing – the act of simulating object behavior and collaboration by acting out an object’s behaviors.
Flyweight: Structural Pattern Prepared by Galina Walters.
DESIGN PATTERNS OZGUR RAHMI DONMEZ.
Patterns Reusable solutions to common object-oriented programming problems When given a programming problem, re-use an existing solution. Gang of Four.
(c) 2009 University of California, Irvine – André van der Hoek1June 13, 2015 – 21:42:16 Informatics 122 Software Design II Lecture 8 André van der Hoek.
Flyweight An Object Structural Design Pattern JM Imbrescia.
Dept. of Computer Engineering, Amirkabir University of Tech. 1 Design Patterns Dr. Noorhosseini Introduction.
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.
DESIGN PATTERNS Redesigning Applications And
(c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.
Design Patterns Module Name - Object Oriented Modeling By Archana Munnangi S R Kumar Utkarsh Batwal ( ) ( ) ( )
Design Patterns academy.zariba.com 1. Lecture Content 1.What are Design Patterns? 2.Creational 3.Structural 4.Behavioral 5.Architectural 6.Design Patterns.
CERN – European Organization for Nuclear Research GS Department – Administrative Information Services Design Patterns in Groovy Nicolas Décrevel Advanced.
Vrije Universiteit amsterdamPostacademische Cursus Informatie Technologie Idioms and Patterns polymorphism -- inheritance and delegation idioms -- realizing.
05 - Patterns Intro.CSC4071 Design Patterns Designing good and reusable OO software is hard. –Mix of specific + general –Impossible to get it right the.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
Design Patterns CSCI 5801: Software Engineering. Design Patterns.
Design Patterns
18 April 2005CSci 210 Spring Design Patterns 1 CSci 210.
Software Design Patterns (1) Introduction. patterns do … & do not … Patterns do... provide common vocabulary provide “shorthand” for effectively communicating.
Computing IV Singleton Pattern Xinwen Fu.
Object Oriented Software Engineering Chapter 16 and 17 review 2014/06/03.
GoF: Document Editor Example Rebecca Miller-Webster.
CSE 403 Lecture 14 Design Patterns. Today’s educational objective Understand the basics of design patterns Be able to distinguish them from design approaches.
Design Patterns CS 124 Reference: Gamma et al (“Gang-of-4”), Design Patterns.
Structural Design Patterns
ECE450S – Software Engineering II
Design Patterns CSIS 3701: Advanced Object Oriented Programming.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns V More Structural Patterns.
Title Carolina First Steering Committee October 9, 2010 Online Voting System Design Yinpeng Li and Tian Cao May 3, 2011.
Introduction to Design Patterns. Questions What is a design pattern? Who needs design patterns? How different are classes and objects in APL compared.
Creational Patterns
What to know for the exam. Smalltalk will be used for questions, but there will not be questions about the grammar. Questions might ask – how particular.
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.
Proxy.
DESIGN PATTERNS COMMONLY USED PATTERNS What is a design pattern ? Defining certain rules to tackle a particular kind of problem in software development.
FACTORY METHOD. Design Pattern Space Purpose ScopeCreationalStructuralBehavioral ClassFactory MethodAdapterInterpreter Template Method ObjectAbstract.
Behavioral Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
CS616: Software Engineering Spring 2009 Design Patterns Sami Taha.
Software Design Patterns Curtsy: Fahad Hassan (TxLabs)
Design Patterns. 1 Paradigm4 Concepts 9 Principles23 Patterns.
Design Patterns Introduction
Design Patterns SE464 Derek Rayside images from NetObjectives.com & Wikipedia.
BEHAVIORAL PATTERNS 13-Sep-2012 Presenters Sanjeeb Kumar Nanda & Shankar Gogada.
STRATEGY PATTERN. Design Pattern Space Purpose ScopeCreationalStructuralBehavioral ClassFactory MethodAdapterInterpreter Template Method ObjectAbstract.
The Flyweight Pattern (Structural) ©SoftMoore ConsultingSlide 1.
Five Minute Design Patterns Doug Marttila Forest and the Trees May 30, 2009 Template Factory Singleton Iterator Adapter Façade Observer Command Strategy.
PROTOTYPE. Design Pattern Space Purpose ScopeCreationalStructuralBehavioral ClassFactory MethodAdapterInterpreter Template Method ObjectAbstract factory.
7 April 2004CSci 210 Spring Design Patterns 2 CSci 210.
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
Chapter 10 Design Patterns.
Chapter 5:Design Patterns
Software Design Patterns
Design Patterns Lecture part 2.
Introduction to Design Patterns
Software Design and Architecture
Flyweight Design Pattern
How to be a Good Developer
Design Patterns with C# (and Food!)
object oriented Principles of software design
Design Patterns
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
Software Engineering Lecture 7 - Design Patterns
Flyweight Pattern 1.
Informatics 122 Software Design II
Presentation transcript:

Katie C. O’Shea Dennis T. Tillman 11 February 2K2 Flyweight

Patterns Presentation Recap Agenda Purpose CreationalStructuralBehavioral ScopeClass Deferring actions to subclasses Composition, inheritance Models that describe algorithms and flow of control Object Deferring actions to other objects Models that describe how to manage objects Specifying how things work together Flyweight

Comp Sci: Pattern  Structural pattern used to support a large number of small objects efficiently  Flyweight factors the common properties of multiple instances of a class into a single object, saving space and maintenance of duplicate instances. Description Definition Flyweight(fli-wat)  Something that is particularly small, light, or inconsequential.

Description Pattern for managing the use of a discreet set of objects. Design Considerations  throughout a system  singularly, independently  in parallel contexts  Reduce costs when sheer quantities of objects require increased storage  Deal with intrinsic and external states independently  Replace groups with shared objects  Application must not rely on object identity Operations Organization Flyweight

CD: a > year > title CD: b > year > title CD: c > year > title :artistFactory Sinatra: artistFlyweight > artistName Nirvana: artistFlyweight > artistName Implementation Portfolio Application Flyweight

Implementation Pattern for managing the use of a small set of objects. Document Processing  throughout a system Flyweight

Implementation Document Processing  throughout a system  In multiple contexts  throughout a system  In multiple contexts Pattern for managing the use of a small set of objects. Flyweight

Structure Row client supports context dependent information — tells children where they should draw themselves by passing location information Word Processor Example Flyweight storing a single character — doesn’t need to know location or font Supplies context dependent information that the Flyweight needs to draw itself Glyph Draw(Context) Intersection(Point, Context)  GLYPH, the abstract class for graphical objects char c Row Draw(Context) Intersection(Point, Context) Column Draw(Context) Intersection(Point, Context) Character Draw(Context) Intersection(Point, Context) Flyweight

Structure Word Processor Example Row client supports context dependent information — tells children where they should draw themselves by passing location information Supplies context dependent information that the Flyweight needs to draw itself Glyph Draw(Context) Intersection(Point, Context)  GLYPH, the abstract class for graphical objects char c Row Draw(Context) Intersection(Point, Context) Column Draw(Context) Intersection(Point, Context) Character Draw(Context) Intersection(Point, Context) Flyweight storing a single character — doesn’t need to know location or font Flyweight

Structure Class Diagram Flyweight

Structure Class Diagram  Creates, manages Flyweights  Dispenses when requested  Ensures sharing  (checks existence)  Maintains references to Flyweight  Supplies context dependent information that the Flyweight needs to draw itself  Implements Flyweight interface  Store intrinsic state  (must be) shareable  For subclasses that do not need to be shared  The Flyweight is the set of intrinsic information that a set of objects share in common. It is abstract. Flyweight

Structure Object Diagram Flyweight

Efficiency Benefits and Consequences +- When Not To Use Flyweight: If the extrinsic properties have a large amount of state information that would need passed to the flyweight (overhead) Need to be able to be distinguished shared from non-shared objects When To Use Flyweight: There is a need for many objects to exist that share some intrinsic, unchanging information Objects can be used in multiple contexts simultaneously Acceptable that flyweight acts as an independent object in each instance If the size of the set of objects used repeatedly is substantially smaller than the number of times the object is logically used, there may be an opportunity for a considerable cost benefit Overhead to track state Transfer Search computation Flyweight

Efficiency Benefits and Consequences v A document uses about 100 character objects (the ASII set) 100 Chars shared in 8,000 char document 100 Chars shared in 200,000 char document Number of Objects Shared f(g): reduction in number of instances amount of intrinsic state state per object computation storage Savings Flyweight

Implementation Applications  Celebrity portfolio, CD Database  Word processing  GUI (skins, look and feel)  Server connection pool Flyweight

Implementation Code Example Balls and Strategies (java) Flyweight

Implementation Related Patterns Purpose CreationalStructuralBehavioral ScopeClass Deferring actions to subclasses Composition and inheritance Models that describe algorithms and flow of control Object Deferring actions to other objects Models that describe how to manage objects Specifying how things work together Flyweight State Strategy Composite Flyweight

Patterns Presentations Catalogued patterns - Recap Purpose CreationalStructuralBehavioral ScopeClass Factory Method Adapter (class)Interpreter Template Method Object Abstract Factory Builder Prototype Singleton Adapter (object) Bridge Composite Decorator Façade Flyweight Proxy Chain of Responsibility Command Iterator Mediator Memento Observer State Strategy Visitor Flyweight