Please join us at the new JavaWorld Q&A Forums. Your existing login will work there. The discussions here are now read-only.


JavaWorld Talkback >> 958324

Pages: 1
Bret Hansen
Unregistered




Not usually applicable
      #609 - 07/30/03 01:29 AM

While the pattern does reduce object creation it is not always as applicable as this article implies. For instance the line drawing example has a huge issue. It can not repaint itself after a blur. The data to paint it is not stored anywhere. The heavy weight version could be readily modified to be re-drawable.

The swing tree node example that displayed the file system does work well, because the state is stored in the file system. If the re-fetch of the data was more expensive (like database or web service) then it would be necessary to maintain sufficient state to repaint.

The article is concise though!


Post Extras: Print Post   Remind Me!   Notify Moderator  
LAH
Unregistered




Re: Not usually applicable [Re: Bret Hansen]
      #643 - 07/31/03 06:26 PM

Good point. Consider whether and where object state information needs to be stored before deciding to use the flyweight pattern, which has no provision for storing state.

Like all design patterns, it's important to know when not to use it.

Thanks!


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1



Extra information
0 registered and 1 anonymous users are browsing this forum.

Moderator:   

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled

Rating:
Topic views: 9305

Rate this topic

Jump to

Contact us JavaWorld

Powered by UBB.threads™ 6.5.5