On Tuesday, August 21, 2001, at 11:31 PM, Sanjiv Kapila wrote:
> Thanks for update.
> I was really on wrong track for flyweight pattern. Thanks again.
> Still i have a query : whether to go for getting data in bunches or
> all at a
> time from a data base. I have been finding ways to divide data in
> multiple
> bunches so that only displayable data is fetched & then re-fetch if
> requested.
> What would you all recommend : fetching data in bunches that can save
> network load or all at a time that wil save no of network /remote
> calls?
Most likely you should fetch it in bunches. You need to run some simple
performance tests with representative data to be sure though. I've
often found the network to be the limiting factor in these cases.
So far as fetching it in bunches, you can use "rownum" in Oracle or
"offset/limit" in MySQL, PostgreSQL, etc.
I actually have a whole section on this in the Bitter Sessions chapter
of _Bitter EJB_. I like to call it the Page-by-Page Iterator pattern.
The Core J2EE Patterns calls it the Value List Handler (a very bad
name, IMHO).
Bob
> Also how do you go for implementing both of these thro JDBC ??
>
> -----Original Message-----
> From: An interest list for Sun Java Center J2EE Pattern Catalog
> [mailto:J2EEPATTERNS-INTEREST@(protected)
> Sent: Friday, August 22, 2003 1:20 AM
> To: J2EEPATTERNS-INTEREST@(protected)
> Subject: Re: Flyweight vs Value Object
>
>
> 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)
>
> ====================================================================
> 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)