|
|
|||||||
|
Love the article (as with all the design patterns ones, it's very useful). However, isn't the Line example just an implementation of a Factory pattern - you don't actually have an unshared flyweight object. To be a true implementation of the flyweight pattern, shouldn't you have your existing Line class holding the intrinsic state (i.e. the colour), then a FlyweightLine class which holds the end points of the line, and a reference to the shared Line object. This would also solve the redrawing problem mentioned by someone else if you held a list of all the FlyweightLine objects. Cheers Jim |