Forums Register Login

my design choice

+Pie Number of slices to send: Send
hi all..
I have almost completed my FBN .but i like to confirm before uploading .
The client design:
i have a dataclient inerface which is implemented by
dataclientremoteImpl which throws remoteexception which is for remote mode
and
i have a dataclientlocalImpl which implements dataclient interface which throws databaseexception,
and i use factory pattern to get the localclasses and remote classes..
but my problem is i use the same class for localimpl as i do for Dataserver..
is it a good approach..
so i have..
Client side:
DataClient interface
DataClientRemoteimpl implements DataClient (remote)
{
}
DataClientLocalimpl implements DataClient (local)
{
// code here is same as DataServerImpl
code xyz
}
server side:
DataServer interface
DataServerImpl implements DataServer
{
code xyz
}


Is it a good approach.....
regards
baiju
+Pie Number of slices to send: Send
So does your GUI call the unlock, lock methods or do you have your dataclient making these calls?

Also, how are you handling the locking on the server side? Did you use RMI or Sockets?
[This message has been edited by Rick Fortier (edited June 13, 2001).]
+Pie Number of slices to send: Send
I am using RMI ..lock and unlock r done at the server ...

baiju
+Pie Number of slices to send: Send
yeah..

from the gui i call lock and unlock..which calls data client which handles the locking mechanish,,
is my approach correct..
baiju
+Pie Number of slices to send: Send
 

Originally posted by baiju:
yeah..

from the gui i call lock and unlock..which calls data client which handles the locking mechanish,,
is my approach correct..
baiju


I would try to separate the low level knowledge of Data from the GUI. It would be better to have the GUI make calls such as BookFlight(FlightNumber, NumSeats), and let a middle service layer do the lock, read, write, unlock Data method calls.
If you made a FlightServices layer then it would know which object to instantiate (Data, or RMIInterface) and can translate the exception classes to a single type (Instead of wrestling with RemoteException and DatabaseException). And when the company grew and wanted to use a real database, then FlightServices could just instantiate a JDBC object and the GUI would not have to be changed at all. So it would give you the ability to have more flexibility, and place your business rules in one place.
This would also allow you to divide the project into more pieces so that your team members could each work on their parts (in a real world situation). So your junior guy could be working on the GUI, and your more senior guys could work on the Services layer and the Data layer. So in a real world situation by dividing up the classes you can get to market faster, and each piece can be debugged separately too.
For instance, I have some nonGUI clients I have created which use the FlightServices layer. I use them to do load/deadlock testing on the server. So I can start a bunch of them at once and let them run for a while to make sure that my design won't easily break. So I have normal test clients which lock - read - unlock and I have bad test clients which just do locks and then die, and I have a client which requests a lock on the whole database. When you run them all at once you can really see if your server is done correctly or not.

[This message has been edited by Rick Fortier (edited June 14, 2001).]
+Pie Number of slices to send: Send
hey..
Thanks for ur comments....
I was just concerned with the way i am handling the remote and local mode..
for remote mode i did use the dataserver
but for the local mode .i cant directly use dataserver since my dataserver implements unicastremoteobject so i need the stubs in localmode too,so to avoid this i did add a seperate class..
so i did create a localimpl which does almost same as what i do in dataserver....Is this a good approach..please do add ur suggestin..

Client side:
DataClient interface
{
all public methods of data class
}
DataClientRemoteimpl implements DataClient (remote)
{
}
DataClientLocalimpl implements DataClient (local)
{
// code here is same as DataServerImpl
code xyz
}
server side:
DataServer interface
{
all public methods of data class
}
DataServerImpl implements DataServer
{
code xyz
}

please comment on it ..
Kind Regards
Baiju r
+Pie Number of slices to send: Send
why to have two different classes for remote & local mode.I think one class should handle this .
+Pie Number of slices to send: Send
hi
i could have used my DataServer to be used in local mode.
but it extends unicastremote object so then i need the stub and skeleton in the client too..
i did not go with the idea of creating a wrapper class with different exception handling..
please do suggest how do i over come this issue.how do i use dataserver directly to avoid a extra class..
regards
baiju
+Pie Number of slices to send: Send
well i guess your DataServer is a wrapper around the Data class object and i think that you are implementing two different interfaces for server & client(why?).Implement the same interface for both and if your DataServer is a wrapper then why not to implement the same interface for Data class.In this way in the client wrapper you could do something like this:
DataInterface d;
public ClientWrapper(---reemote--){
d=Naming.loo____
}
public ClientWrapper(----local---){
d=new Data(---)
}
+Pie Number of slices to send: Send
yeah..
again thanks for ur comment..
u r correct.but my problem is to use the DataServerImpl
for both the local and remote is Unicastremote object..
i could use in DataServerImpl

public class DataServerImpl extends unicastremoteobject implement Dataserver{
connect()
{
d=Naming.loo____//remote mode
and
d=new Data(---)//when local use the data class
}
}
but then i need stubs in the local mode too...
Is it okay i did this but i thought for local mode i dont need
stubs..but is this approach correct..
so to avoid rmic for local mode..how to do it..so i created a sperate class which does the same as my rmi server class for local mode...
please do comment..
Kind Regards
Baiju
+Pie Number of slices to send: Send
I think I did not make myself clear Now is the DataServerImpl a wrapper class that wraps a data class object or is it something else In my last post I made the assuption that it was a wrapper.In that case the question of a stub does not arise on the local mode.I think it is not a very good idea to have two classes when one can do------polymorphism??
+Pie Number of slices to send: Send
i have 2 options ..
1st approach.......
Yeah since if i unicast remote object i need stubs and skeleton in local mode too..
2nd approach(which i am currently using)
i have implementation for remote and local mode two different classes.but both do the same thing..

DataServer interface{
//all the public methods of data class
}
.............remote mode.........................
class DataServerImpl extends unicastremoteobject implements DataServer
{
//i do the rmi registry
//implements all the dataclass public methods..
}
..................local mode.......................
class DataLocalImpl implements DataServer
{
//d=new Data();
//implements all the dataclass public methods..
}

but here i use the same code in both local and remote..
hope now its clear.so i personally dont like this but i cant see any other approach.else i need to do lot of exception handaling specific to remote and local.
Is it a good approach can i do this.please comment on it.
waiting for ur replay
+Pie Number of slices to send: Send
Taking your second approach for a moment why 2 classes if you can make your Data class implement the DataServer interface then only the exceptions never have to catch them specifically for local & remote
+Pie Number of slices to send: Send
and in the implementation you can delegate calls to the DataServer
+Pie Number of slices to send: Send
thanks again .sorry for trouble u all..
yeah my dataserver is a interface how do i delegate it..
more over my DataServerImpl implements unicasteRemoteObject if i do as u did ...then again i need the stub and skeleton..
could u explain how do i delegate from my DataserverImpl to handle local mode..
can u just show some small example..

please do write back....
regards
baiju
+Pie Number of slices to send: Send
please i will appreciate more comments
Can you shoot lasers out of your eyes? Don't look at this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 995 times.
Similar Threads
RemoteException and DatabaseException
Please review Server design
Design Question...
release the critics, here comes a design
Naming.Lookup and Rebind
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 23:30:00.