example for flyweight pattern

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Arthur

    example for flyweight pattern

    hey all,

    imagine the following:

    a screen full of circles. each circle has coordinates and a style. the
    coordinates are always different, a style can be the same among 0 to
    many circles.

    what would be the correct implementateion of the flyweight pattern?

    a) one (circle-)object for every different style, and the coordinates
    for all circles stored in the context.
    b) one circle-object for every different set of coordinates and the
    styles stored in the context.

    and in general: how would you solve this issue most memory efficient,
    if not by one of the two answers above (imagine billions of circles
    and tenthousands of styles)?

    thanks
Working...