aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Client design Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Client design" Watch "Client design" New topic
Author

Client design

Kumar Bhaskar
Greenhorn

Joined: Jun 03, 2004
Posts: 5
I am working on my URLy Bird project and wrote a few programs like reading from and writing to the db file.

I got the interface DBAccess and the data access class must be called Data.java.

For the client-server design, I plan to use RMI as follows:

Interface RemoteData extends Remote and has the methods
getData
searchRooms
bookHotelRoom

RemoteDataImpl extends UnicastRemoteObject implements RemoteData
getData returns a new Data object.

The GUI client calls DataFactory.getRemote(). This method does a look up on the server, casts the return to RemoteData, and returns getData i.e a new Data object.

The client receives the Data object, so it cannot execute the searchRooms and bookHotelRoom methods. Also, the Data class has local RAFs in its methods for I/O and RAFs are not serializable. So the client should not receive the Data object, I think.

I'm stuck here and would like your comments before I proceed.

Should RemoteData extend both Remote and DBAccess? Is it absolutely necessary for it to extend DBAccess.

From the DBFactory, should the client get the RemoteData object itself and not Data?

Thanks,
K D Bhaskar
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11503
    
  95

Hi Kumar,

Welcome to JavaRanch and this forum.


Interface RemoteData extends Remote and has the methods
getData
searchRooms
bookHotelRoom


Why do you have both business logic methods (searchRooms & bookHotelRooms) and access to the low level methods (via getData) exposed to your client? Most candidates seem to go one way or the other. The either have just the high level business methods, or the low level access to Data class.


The GUI client calls DataFactory.getRemote(). This method does a look up on the server, casts the return to RemoteData, and returns getData i.e a new Data object.


Why are you calling the getData method? Shouldn't you be returning an instance of RemoteData which will then have the business methods?

Also, the Data class has local RAFs in its methods for I/O and RAFs are not serializable. So the client should not receive the Data object, I think.


Agreed.


Should RemoteData extend both Remote and DBAccess? Is it absolutely necessary for it to extend DBAccess.


You will probably find that RemoteData cannot extend both interfaces, as DBAccess probably does not throw the "right" exceptions for you.

(Which is a round about way of saying that it shouldn't extend both).


From the DBFactory, should the client get the RemoteData object itself and not Data?


Yes.

Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Kumar Bhaskar
Greenhorn

Joined: Jun 03, 2004
Posts: 5
Andrew,

Thanks for your reply.

I have replaced the getData method with another method that returns column names and records to the client. This is required for the initial display.

The other questions I asked in my posting were not related to my actual problem. The GUI client was still throwing exceptions and the System.out.println statements were not helping me much. Finally I found that the file I was selecting for the server was a zero byte file.

K D Bhaskar
[ June 17, 2004: Message edited by: Kumar Bhaskar ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Client design