wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes A funny case. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "A funny case." Watch "A funny case." New topic
Author

A funny case.

Anton Golovin
Ranch Hand

Joined: Jul 02, 2004
Posts: 476
I am caching the data file in a HashMap in the implementation of the Data class. So, basically, in LOCAL mode, this means that my data model (RoomTableModel extends AbstractDataModel) gets not its own set of objects but references to the cached objects. I have to copy the objects so that my RoomTableModel gets its own separate copy of each record it is passed. Maybe someone would kindly comment if this solution is a good one. It seems to be the only one when caching and local mode, and I am far too much into the project to back out of caching (it also offers great search performance.) Do you think this copying would negatively affect my grade?

Thanks!


Anton Golovin (anton.golovin@gmail.com) SCJP, SCJD, SCBCD, SCWCD, OCEJWSD, SCEA/OCMJEA [JEE certs from Sun/Oracle]
Philippe Maquet
Bartender

Joined: Jun 02, 2003
Posts: 1872
Hi Anton,

I think that passing *copies* of the cached records to the presentation layer totally makes sense. So you're OK IMO, but it's only my opinion of course.

Regards,

Phil.
mike acre
Ranch Hand

Joined: Sep 23, 2003
Posts: 197
A very admirable design goal is to make as many classes immutable as possible. This is especially true of transfer objects. If this is achieved there is no need to make copies.


SCJP 1.4, SCJD
Anton Golovin
Ranch Hand

Joined: Jul 02, 2004
Posts: 476
Originally posted by mike acre:
A very admirable design goal is to make as many classes immutable as possible. This is especially true of transfer objects. If this is achieved there is no need to make copies.


Ah, but my design has 19 classes. I have no transfer objects and use a Map to move data. I think they are looking not for design here but for documented problem-solving, and my project has a few things where problems were solved. It's a thin client, so there is some stuff that needed solving.
[ September 24, 2004: Message edited by: Anton Golovin ]
Andy Zhu
Ranch Hand

Joined: May 26, 2004
Posts: 145
Hey, Anton:

I got confused about your post. I have an adapter to my data class. I guess, no matter the client is local or remote. I am implementing a thin client, so that business logic is at adapter (I used cache too). but in half way of coding client. But so far I don't need to have another copy of the cache, not even in the adapter. In adapter, I don't give the choice of transfer whole cache to the client.

From the point of space efficiency, make a client copy is not a good practice, you waste half of your memory your program used (we are talking the local mode, so the client and server sit on the same machine).


--------<br />Andy Zhu<br />scjp 1.4<br />scjd 1.4<br />SAS Certified Programmer 9.0
Anton Golovin
Ranch Hand

Joined: Jul 02, 2004
Posts: 476
Originally posted by Andy Zhu:
Hey, Anton:

I got confused about your post. I have an adapter to my data class. I guess, no matter the client is local or remote. I am implementing a thin client, so that business logic is at adapter (I used cache too). but in half way of coding client. But so far I don't need to have another copy of the cache, not even in the adapter. In adapter, I don't give the choice of transfer whole cache to the client.

From the point of space efficiency, make a client copy is not a good practice, you waste half of your memory your program used (we are talking the local mode, so the client and server sit on the same machine).


Wait till you write the client GUI and implement your own TableModel. Then, you will be forced to copy the values.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A funny case.