I agree these are different patterns. They are related though: The
Flyweight Pattern can serve as an efficient implementation of the Value
Object pattern.
The Value Object pattern is abstract in the sense that it tells you to do
proper domain modeling and capture as Value Objects what are values from a
modeling perspective.
Typically, you implement Value Objects as immutable objects/Flyweight
Pattern. (Sorry, my copy of the GOF book is in storage so I'm not sure the
match Immutable/Flyweight is 100%).
But not always. You can use the Body/Handle idiom, copy on write, etc.
We wrote up such implementation techniques for anyone interested at:
http://www.riehle.org/computer-science/research/1998/ubilab-tr-1998-10-1.html
Also, there is always JValue if you are interested in doing it in Java:
http://www.jvalue.org
Dirk
At 8/21/2003 -0300, tetsuo wrote:
>It simply isn't the pattern described by the GoF. The intent of the
>Flyweight design pattern is to "use sharing to support large numbers of
>fine-grained objects efficiently."
>
>An example of it is the design of the Swing's JTable. It uses a model,
>which provides information about the cells of the table, but doesn't
>hold any rendering data. When rendering time, one CellRenderer object is
>configured with one cell's data and context (position, selection, etc) a
>time, and is responsible for rendering it properly. This way, the table
>model doesn't have to hold rendering information (position, color,
>border, etc), only its contents.
>
>For handling large sets of data tuples, there is a pattern in "J2EE Core
>Patterns", called ValueListHandler. Its 1st Edition is published at
>Sun's site:
>
>http://java.sun.com/blueprints/corej2eepatterns/Patterns/index.html
>
>and its 2nd Edition has been released recently (my copy will arrive
>soon), with updated and new patterns.
>
>regards
>Tetsuo
>
>
>Sanjiv Kapila wrote:
>
>>Can any one highlight me pros & cons of Flyweight vs Value Object paatern.
>>As per my understanding Flyweight calls for dividing the result or their
>>transfer across n/w in smaller bunched to avoid overloading whereas value
>>object clubs diff. request in one to save multiple calls over network.
>>
>>Also I would like to know code snippet for making a flyweight pattern i.e.
>>segregating a resulset in multiple bunches. I know we have fetchSize() that
>>can define the no of records to fetch but how to indicate that pointer for
>>starting record. Also what will happen if during this fetching some new
>>records are inserted in the requested table?
>>
>>Regards
>>Sanjiv
>>
>>====================================================================
>>Companion Site: http://www.corej2eepatterns.com
>>J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns
>>List Archive:
>>http://archives.java.sun.com/archives/j2eepatterns-interest.html
>>Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected)
>
>====================================================================
>Companion Site: http://www.corej2eepatterns.com
>J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns
>List Archive: http://archives.java.sun.com/archives/j2eepatterns-interest.html
>Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected)
----
Cell Phone: (650) 224 0233 --- Web Site: http://www.riehle.org
====================================================================
Companion Site: http://www.corej2eepatterns.com
J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns
List Archive: http://archives.java.sun.com/archives/j2eepatterns-interest.html
Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected)