aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes FBN Design Doubts Please Help!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "FBN Design Doubts Please Help!!" Watch "FBN Design Doubts Please Help!!" New topic
Author

FBN Design Doubts Please Help!!

Vikas Sood
Ranch Hand

Joined: Sep 03, 2002
Posts: 109
Dear friend
This is me Vikas From India,and following are my design choices for SCJD.
1) Modify Data class,and make it implement DataService interface which contains all the public methods of the Data classs.I am making all these public methods in DataService interface throw Exception(as this is being extended by RemoteDataService interface which does not have any methods of its own,but just extends DataService inteface apart from extending Remote interface).
a)Planning to implement Lock and Unlock in Data class only using an singleton object of LockHandler class.Will use current Thread as sort of client id without changing the lock unlock signature.
But am in doubt as i know that threads servicing clent calls in Rmi can interchange between clients ,i.e a client can be making use of diffrent threads for calls to remote object ,but i think this can be overcome by using a composite method on the server like bookSeats() in my case to carry out locking and unlocking in a sequence.And i think there is not going to be any case in which a perticular record doesnot get unlocked after booking of seats, as the client will just call the bookSeats method and the rest is going on the server as sequence.I dont need to do anything to remove locks of dead clents this way.Am i right over here? plz do comment.
Will also have functionality for locking and unlocking whole database also.
b)CriteriaFind method will make use of a CriteriaFinder class for searching o a criteria.Will be generic capable of searching on the basis of any options in the Db.But the GUI will only provide two combo boxes for allowing search on the basis of origin and destination.
c)Will addd an bookSeats method to Data class which will be called by the client side for booking of a perticular seat as per requirement in this order :
public boolean bookSeats(int recNum){
lock();
getRecord();
modify();
unlock();}
2) RemoteData adapts Data,i.e. i am creating a instance of Data in the constructor of Data class(Do i need to use singleton pattern over here or just a private instance will make do?)and passing on all the calls to RemoteData methods to this Data instance.This class implements RemoteDataService and extends from UnicastRemoteObject.This classs is binded to the RMI registry using an RMIServer class.
3) On the Client side DataClient makes use of a factory class in its constructor,so as to connect to Db as per the user input (for Local or Network connection).DataClint has all the public methods of Data class and also implements DataService interface.This class initialises a DataService reference with an object of Data or RemoteData as per the chosen mode.And all client calls to DataClient methods are passed on to the Data or Remote Data class methods.(But i think we are not supposed to have locking in the local mode,how can i achive that over here,do i need to pass on the logic of locking on to the RemoteData class,and should i leave the Data implementation o lock () nad unlock empty?)
What do u think about the above design choices am on the right track.Thank you in advace for helping me out.
Please Help I am really stuck between these decisions. I can not move forward?
Vikas Sood
New Delhi
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

"Vikas"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it
here.
Thanks! and welcome to the JavaRanch!
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Vikas Sood
Ranch Hand

Joined: Sep 03, 2002
Posts: 109
HI Mark,
I have changed my display name ,can u help me with my doubts I am stuck at the moment,can u go through my message in the thread and kindly give me ur inputs.
vikas
Originally posted by Mark Spritzler:
"Vikas"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it
here.
Thanks! and welcome to the JavaRanch!
Mark
parthiban subramaniam
Ranch Hand

Joined: May 15, 2002
Posts: 116
Hi vikas,
===========================
1) Modify Data class,and make it implement DataService interface which contains all the public methods of the Data classs.I am making all these public methods in DataService interface throw Exception(as this is being extended by RemoteDataService interface which does not have any methods of its own,but just extends DataService inteface apart from extending Remote interface).
========================
looks good
=========================
a)Planning to implement Lock and Unlock in Data class only using an singleton object of LockHandler class.Will use current Thread as sort of client id without changing the lock unlock signature.
But am in doubt as i know that threads servicing clent calls in Rmi can interchange between clients ,i.e a client can be making use of diffrent threads for calls to remote object ,but i think this can be overcome by using a composite method on the server like bookSeats() in my case to carry out locking and unlocking in a sequence.And i think there is not going to be any case in which a perticular record doesnot get unlocked after booking of seats, as the client will just call the bookSeats method and the rest is going on the server as sequence.I dont need to do anything to remove locks of dead clents this way.Am i right over here? plz do comment.
==========================
handling the locks looks good .. but do you have to put the book seats which is a application specific one in the server ?? server is to serve data and to manipulate it .. not to handle any application specific logic thats my view
what if the book seats operation logic changes in the future ?? you will have to modify the server code and if it depends on some other application's state .. you get a big hit there ..

===================================
Will also have functionality for locking and unlocking whole database also.
b)CriteriaFind method will make use of a CriteriaFinder class for searching o a criteria.Will be generic capable of searching on the basis of any options in the Db.But the GUI will only provide two combo boxes for allowing search on the basis of origin and destination.
=================================
some handle the CriteriaFinder in the data class some in a seprate helper class .. its upto you ..
=============================
c)Will addd an bookSeats method to Data class which will be called by the client side for booking of a perticular seat as per requirement in this order :
public boolean bookSeats(int recNum){
lock();
getRecord();
modify();
unlock();}
=========================
think more abut this .. is this the right place to put this ?? if u have many application specifc methods added in the data class the data class it will become hard to maintain ...
========================
2) RemoteData adapts Data,i.e. i am creating a instance of Data in the constructor of Data class(Do i need to use singleton pattern over here or just a private instance will make do?)and passing on all the calls to RemoteData methods to this Data instance.This class implements RemoteDataService and extends from UnicastRemoteObject.This classs is binded to the RMI registry using an RMIServer class.
=====================
yeah .. we dont want multiple data classes do we ?? say u r editing a txt file .. you wont open mutiple instance of notepad and open the same text file and edit it .. changes made by one will not be reflected in other ..

=========================
3) On the Client side DataClient makes use of a factory class in its constructor,so as to connect to Db as per the user input (for Local or Network connection).DataClint has all the public methods of Data class and also implements DataService interface.This class initialises a DataService reference with an object of Data or RemoteData as per the chosen mode.And all client calls to DataClient methods are passed on to the Data or Remote Data class methods.(But i think we are not supposed to have locking in the local mode,how can i achive that over here,do i need to pass on the logic of locking on to the RemoteData class,and should i leave the Data implementation o lock () nad unlock empty?)
======================
looks good
====================
What do u think about the above design choices am on the right track.Thank you in advace for helping me out.
===================
over all it looks good .. needs few touch up's here and there .. as you start to work on it you will find them your self
hope this helps,
cheers,
parthi.


Even crazy and silly looking problems are sometimes real.
Padmaja Prasad
Ranch Hand

Joined: Nov 14, 2001
Posts: 76
Hi Vikas,

a)Planning to implement Lock and Unlock in Data class only using an singleton object of LockHandler class.Will use current Thread as sort of client id without changing the lock unlock signature.
But am in doubt as i know that threads servicing clent calls in Rmi can interchange between clients

Yes, you are right. To overcome this, I (and most of ranchers) implemented lock & unlock in Remote implementation class and used "this" as the client ID and passed "this" & "recNum" to the LockManager class's lock() & unlock() methods. But in this case you must supply seperate Remote Data for each client request. You can attain this by means of a Factory pattern. And the lock() & unlock() methods in Data class are no-ops.
Regarding book seats(read, lock, read, modify, unlock), I agree with Parthiban. I have implemented that in client side.

2) RemoteData adapts Data,i.e. i am creating a instance of Data in the constructor of Data class(Do i need to use singleton pattern over here or just a private instance will make do?)

I read in this forum that Data must be reusable. So Sigleton pattern is not a good idea. As for as the other option is concerned, I think the private instance of Data must be static.

3) On the Client side DataClient makes use of a factory class in its constructor,so as to connect to Db as per the user input (for Local or Network connection).DataClint has all the public methods of Data class and also implements DataService interface.

My DataClient (client side) class has a reference to an object of type DataInterface,(not all public methods) and it has some business logic methods such as book seat, search db. Client side GUI uses this class to access the db & display contents.
Hope this helps,
Padmaja
Vikas Sood
Ranch Hand

Joined: Sep 03, 2002
Posts: 109
Hi parthiban subramaniam & Padmaja Prasad
Thankx for ur remarks,I will like to discusss the following further,
========================== I wrote ====================
1)Planning to implement Lock and Unlock in Data class only using an singleton object of LockHandler class.Will use current Thread as sort of client id without changing the lock unlock signature.
But am in doubt as i know that threads servicing clent calls in Rmi can interchange between clients ,i.e a client can be making use of diffrent threads for calls to remote object ,but i think this can be overcome by using a composite method on the server like bookSeats() in my case to carry out locking and unlocking in a sequence.And i think there is not going to be any case in which a perticular record doesnot get unlocked after booking of seats, as the client will just call the bookSeats method and the rest is going on the server as sequence.I dont need to do anything to remove locks of dead clents this way.Am i right over here? plz do comment.
********************parthiban Your sugessions *********************
handling the locks looks good .. but do you have to put the book seats which is a application specific one in the server ?? server is to serve data and to manipulate it .. not to handle any application specific logic thats my view
what if the book seats operation logic changes in the future ?? you will have to modify the server code and if it depends on some other application's state .. you get a big hit there ..
********************Padmaja Your sugessions *********************
Yes, you are right. To overcome this, I (and most of ranchers) implemented lock & unlock in Remote implementation class and used "this" as the client ID and passed "this" & "recNum" to the LockManager class's lock() & unlock() methods. But in this case you must supply seperate Remote Data for each client request. You can attain this by means of a Factory pattern. And the lock() & unlock() methods in Data class are no-ops.
Regarding book seats(read, lock, read, modify, unlock), I agree with Parthiban. I have implemented that in client side.
&&&&&&&&&&&&&&&&&&&&&& My current Post&&&&&&&&&&&&&&&&&&&&&
I think I get ur point here,by putting bookSeats on the server i am not going to have generic server,which can be later on used for acessing and using other db files apart from the FBN assignment file.But if i have the bookSeats defined on the client side than i will have to think about client identification through some other way(inside lock and unlock methods) as there is not going to be any guarantee of reusing the same thread (if used as a client ID)in between client calls to the Rmi server.Should i change the structure of lock and unlock, such that it makes use of a remote object as client id generated using factory pattern (connection object returned per client for acessing the Rmi server which in turn makes available an remote instance of RemoteData to be used for server access.)Will this be the right approach?

----------------------------------------------------------------------------
========================== I wrote ====================
2) RemoteData adapts Data,i.e. i am creating a instance of Data in the constructor of Data class(Do i need to use singleton pattern over here or just a private instance will make do?)and passing on all the calls to RemoteData methods to this Data instance.This class implements RemoteDataService and extends from UnicastRemoteObject.This classs is binded to the RMI registry using an RMIServer class.
********************parthiban Your sugessions *********************
yeah .. we dont want multiple data classes do we ?? say u r editing a txt file .. you wont open mutiple instance of notepad and open the same text file and edit it .. changes made by one will not be reflected in other ..

********************Padmaja Your sugessions *********************
I read in this forum that Data must be reusable. So Sigleton pattern is not a good idea. As for as the other option is concerned, I think the private instance of Data must be static.

&&&&&&&&&&&&&&&&&&&&&& My current Post&&&&&&&&&&&&&&&&&&&&&
That is true thats why i was thinking of allowing only instance of Data to be usedfor data access,and what i understand from Singleton pattern is that this is what it provides us.And also by making Data reference negative am i not making it global member that is a single instance.Plz correct me if i am wrong?
------------------------------------------------------------------------------
========================== I wrote ====================
3) On the Client side DataClient makes use of a factory class in its constructor,so as to connect to Db as per the user input (for Local or Network connection).DataClint has all the public methods of Data class and also implements DataService interface.This class initialises a DataService reference with an object of Data or RemoteData as per the chosen mode.And all client calls to DataClient methods are passed on to the Data or Remote Data class methods.(But i think we are not supposed to have locking in the local mode,how can i achive that over here,do i need to pass on the logic of locking on to the RemoteData class,and should i leave the Data implementation o lock () nad unlock empty?)
********************parthiban Your sugessions *********************
looks good

********************Padmaja Your sugessions *********************
My DataClient (client side) class has a reference to an object of type DataInterface,(not all public methods) and it has some business logic methods such as book seat, search db. Client side GUI uses this class to access the db & display contents.
&&&&&&&&&&&&&&&&&&&&&& My current Post&&&&&&&&&&&&&&&&&&&&&
So that means its ok to have the Data lock and unlock methods empty?Is it right?Another Q
what are the contents of client and server packages ?Do u have copies of Data and support classes in both the packages? i am planning to have them in both packages.Do i also have to put the DataService interface also at both the places,if yes then will the two instances of DataService in these two packages which have seperate package declerations be compatible ,then how will an ref. of DatService at client package be assigned an DataService instance of server package (extended and implemented remotely with RemoteDtaService interface and RemoteData class on the server.Can u explain?
---------------------------------------------------------------------------

Thankx once again ur inputs have cleared a lot of my doubts,looking forward to ur sugessions .
Vikas Sood
Vikas Sood
Ranch Hand

Joined: Sep 03, 2002
Posts: 109
Hi guys,
Can anybody else also look into my design choices and comment on them?
Another thing on having the bookseat on client side may make the chamges to client end very difficult as the clients might be distributed on to various locations,while making changes on to server might be easier as changes have to be carried aout at one location only.So would'nt it be better to have a generic client istead of server?
please comment!
Vikas Sood
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: FBN Design Doubts Please Help!!