Flyweight Pattern Melbourne Patterns Group 4 April 2007
Upcoming SlideShare
Loading in...5
×
 

Flyweight Pattern Melbourne Patterns Group 4 April 2007

on

  • 1,632 views

Flyweight Pattern Melbourne Patterns Group

Flyweight Pattern Melbourne Patterns Group

Statistics

Views

Total Views
1,632
Views on SlideShare
1,555
Embed Views
77

Actions

Likes
0
Downloads
42
Comments
0

3 Embeds 77

http://melbournepatterns.wordpress.com 43
http://melbournepatterns.org 33
http://www.slideshare.net 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Flyweight Pattern Melbourne Patterns Group 4 April 2007 Flyweight Pattern Melbourne Patterns Group 4 April 2007 Presentation Transcript

  • Flyweight Pattern ‘Use sharing to support large numbers of fine-grained objects efficiently.’ Derek Weeks Melbourne Patterns Group Wednesday 4 April 2007 www.linkedin.com/in/derekweeks
  • Intent
    • Use sharing to support large numbers of fine-grained objects efficiently.
  • Problem
    • Want to design objects at a granular level
    • But...
    • Don’t want your app to run like a (slow) dog
  • Example
    • System for batch processing of orders (online groceries)
    • Identical items appear in many orders
    • Want to represent items as objects (why?)
    • Each item has state
      • Price
      • Size
      • Current storage area
      • Weight
      • Which order it belongs to
    • To share item objects, we need to separate the intrinsic state from the extrinsic state
    • What methods do item objects expose?
  • Flyweight Class Diagram
  • Implementation of Example
  • When to use flyweight
    • When all of the following are true
      • Large number of objects used
      • Storage costs are high
      • Most state can be made extrinsic
      • High proportion of objects shareable
      • No requirement for object identity
  • Discussion
    • Often combined with Composite pattern
    • Who has used this before?
    • Any traps to watch out for?
    • Is performance the only benefit?