There is a reason that the J2EE "Value Object" pattern was renamed to
"Data Transfer Object" pattern. The "Value Object" pattern is a very
commonly accepted standard that predated the J2EE use of the name. You
can look at archives for this mailing list for discussions about the
"classic" value object pattern versus the data transfer object pattern.
Martin Fowler's Patterns of Enterprise Application Architecture book
also covers this subject well.
A Money object as the typical example of the value object pattern -- an
instance of Money represents a particular immutable value. We make
value objects immutable to communicate what happens when the value is
changed (we get a new object so anybody holding a reference to the old
object are not affected by this change).
-----Original Message-----
From: Kalra, Ashwani [mailto:ashwani.kalra@(protected)]
Sent: Friday, August 22, 2003 7:04 AM
To: J2EEPATTERNS-INTEREST@(protected)
Subject: Re: Flyweight vs Value Object
Sanjeev Fly weight and Value object are totally different. One is GOF
pattern and other is j2ee pattern . later is now called DTO. As the
name implies, it is used to transfer data across different tiers in
coarse form to overcome the network calls. Fly weight pattern is used
when application is using large no of ||ar object which differ only in
certain respect.
take the case of simple editor. Each letter is represented by say a
object.Now when you are typing letter 'a' very often it only differs
with others only wrt its position. So instead of creating new instance
for each 'a' , I will put this in some sort of common pool and while
displaying it , I will pass some information (here the position). This
way you can save the memory and overhead associated with the creation of
the object. For more details refer to GOF book.
/Ashwani
> -----Original Message-----
> From: Sanjiv Kapila [mailto:skapila@(protected)]
> Sent: Tuesday, August 21, 2001 11:52 AM
> To: J2EEPATTERNS-INTEREST@(protected)
> Subject: Flyweight vs Value Object
>
>
> 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)
>
____________________________________________________
This message contains information that may be privileged or confidential
and is the property of the Cap Gemini Ernst & Young Group. It is
intended only for the person to whom it is addressed. If you are not the
intended recipient, you are not authorised to read, print, retain, copy,
disseminate, distribute, or use this message or any part thereof. If you
receive this message in error, please notify the sender immediately and
delete all copies of this message.
====================================================================
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)