aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Design Choice...(Post your opinions) 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 "Design Choice...(Post your opinions)" Watch "Design Choice...(Post your opinions)" New topic
Author

Design Choice...(Post your opinions)

Suresh Babu Seeram
Greenhorn

Joined: Feb 04, 2002
Posts: 27
Design Choices:
db:
--Data (class)
.. I decided not to modify this class.. I want extend this..class

--DataAccess(Interface)
...defines all public methods of Data Class
...all methods doesn't throw any exceptions
...it doesn't contains criterFind() ..as it is not present in original Data class

--DataAccessLocal(Interface) extends DataAccess
...method throws databaseExceptinons & IOExceptions
...It contains additionally criteriaFind() method
--DataAccessRemote(Interface) extends Remote,DataAcess
...methods throws DataBase,Remote & IO Exceptions.
--DataAccesFactory(interface)
...returns DataAccessLocal or DataAccessRemote.
--DataAccessFacade (Interface)
...contains searchFlight();.bookFlight() methods..

--LocalData(class) extends Data,implements DataAccessLocal
--RemoteData(class) extends Data,implements DataAccessRemote.

server:

--DataServer(class) extends UnicastRemoteObject,implements DataAccessRemote
...RemoteData Class is wrapped within

--LockManager class..
... I have no idea How to implement this class....

--ConnectionFactory


client:
--DataClient(class) implements DataAccessLocal
...LocalData Class is Wrapped with in...

--StartGUI(classs)
--DataAccessFacadeImpl(class) implements DataAccessFacade.
...It will use DataAccessFactory class to get the..
DataAccessLocal or DataAccessRemote..
*************************************************
Hi Mark,Sai and Others..
I have given my intial design choice with my rudimentary knowledge.. Because I am new to design pattern.... I need your help to get good design..
Please post your opinion on above design.
I have few doubts..
1. Please explain how LockManager class will implememnt.
2. How ConnectionFactory will implement here..
Thanks in advance...
regards,
Suresh
Sai Prasad
Ranch Hand

Joined: Feb 25, 2002
Posts: 560
My recommendations:
1) You don't need LocalData and RemoteData. All you need is a Data class.
2) Since DataAccessLocal, DataAccessRemote and DataAccess are not that different except for the exceptions being thrown, stick to one interface DataAccess and include criteriaFind() in that interface. Also have all the methods in that interface throw the appropriate exceptions.
3) You need to create an interface that extends Remote for the ConnectionFactory to implement
4) I would rename the DataClient to DataProxy
LockManager:
There are two things you need to take care of while locking a record by a client.
1) You need to make sure that the client who locked a record is now trying to unlock it. This is the functionality of the LockManager
2) You need to block the threads (created by RMI system) trying to lock a record which is already locked. This can be in the LockManager or in the Data class. You make the decision.
ConnectionFactory:
Responsible to return an instance of DataServer to the clients. No need to keep track of who is calling the factory method.
Suresh Babu Seeram
Greenhorn

Joined: Feb 04, 2002
Posts: 27
Hi Sai,
Thanks for quick reply..
From your recommendations...design will change like this..
Design:
db:
--Data(class)implements DataAccess
..modify this class (it also implements criteriaFind())

--DataAccess(Interface)
...defines all public methods of Data Class
...all methods throws Exception

--DataAccessRemote extends Remote,DataAcess
...methods throws DataBase,Remote & IO Exceptions.


--DataAccesFactory(interface)
...returns DataAccess or DataAccessRemote.
--DataAccessFacade (Interface)
...contains searchFlight();.bookFlight() methods..
server:

--DataServer(class) extends UnicastRemoteObject,implements DataAccessRemote
...Data Class is wrapped within

--LockManager class..

--ConnectionFactory


client:
--DataProxy(class) implements DataAccess
...Data Class is Wrapped with in...

--StartGUI(classs)
--DataAccessFacadeImpl(class) implements DataAccessFacade.
...It will use DataAccessFactory class to get the..
DataAccessLocal or DataAccessRemote..
1.From the above design.. We are modifying Data Class with full implementation of (with record locking..)lock(),unlock(),criteriaFind() methods.. but record locking is not necessary in Local mode ..
2. I have one choice in my mind. I will neither modify the Data Class nor Subclass it..
I will have DataAcess,DataAccessRemote interfaces.
--DataServer implements DataAccessRemote with implementation of record locking ... Data Class is wrapped within this class for other methods..
--DataProxy implements DataAccess.It It wrapps Data class with in for all methods.. except criteriaFind()
If I am doing above design #2.. then I am deviatiing Sun's Instruction
Part of your assignment will be to enhance the Data class. You may do this by modification or subclassing, but you should document the approach and reason for your choice.


3.

Sai-- I would rename the DataClient to DataProxy

Could you please elaborate above..
4.
Sai-- 3) You need to create an interface that extends Remote for the ConnectionFactory to implement

Could you please explain this with simple example.
regards,
Suresh
[ June 20, 2002: Message edited by: Suresh Babu Seeram ]
[ June 20, 2002: Message edited by: Suresh Babu Seeram ]
Sai Prasad
Ranch Hand

Joined: Feb 25, 2002
Posts: 560
No need to have two interfaces, DataAccess and DataAccessRemote. Data, DataServer and DataProxy all implements one interface DataAccess. Methods in DataAccess can throw the necessary exceptions including RemoteException. I didn't extend the Data but you need to make this design decision and document it.
But you have to extend or modify it. Here is the flow:
DataAccessFacadeImpl -> DataAccessFactory
DataAccessFacadeImpl -> DataProxy
DataAccessFactory either creates or locates the Data instance and assign that instance to the DataProxy and returns this *proxy* instance to DataAccessFacadeImpl.
You need to create a remote interface with one method to return your DataServer instance. This method will be called by the clients when they need the DataServer instance in the remote mode. ConnectionFactory implements this interface and extends UnicastRemoteObject.
[ June 20, 2002: Message edited by: Sai Prasad ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Design Choice...(Post your opinions)