• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Design issues

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,
I have a doubt regarding design which iam following
* In order to make all the public methods of Data.java to be avilable in the RemoteClient
I have an interface DataInterface.java which will have all the public method of Data.java
* Now i have one more interface which will extend
DataInterface and Remote interface of rmi, Which named as RemoteDataInterface.java
* Now i have two implementation class as follows
one for remoteAccess and another for localAccess
1. RemoteDataAccess extend UniCastReportObject implements RemoteDataInterface

2. LocalDataAccess implements DataInterface
* Finally i have a ClientFactory class which has a
method as follows
Public class ClientFactory
{
DataInterface getConnection()
{
//will return RemoteDataAccess
or LocalDataAccess based on the user choice
}
}

Guys those who completed JD pleasec give me ur valid comments on my design so that i can proceed.
thanks & regards
-dhana
 
dhana sekar
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All,
Please go through the above Design of mine
and give me ur valuable feedback.

thanks & regards,
dhana
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks good. I'd only change one thing and this is nitpicking, so you can ignore it if you wish.

DataInterface getConnection()


I'd call this method getDataAccess, or something along those lines. When I think of getConnection, I think of a connection object to a remote server.
I think your Factory that gets bound to RMI will have a method called this.
Mark
 
dhana sekar
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,
Thanks Mark for valuable feedback. Now i did a small in the above design as follows.
*LocalDataAccess extends Data implements DataInterface
* Incase of ClientFactory class i have a method getConnection(String mode), Because if the mode is remoteClient then i do a Naming.lookUp() and return the DataInterface to the caller where it will be typecasted as RemoteDataAccess.
Mark is it ok waiting for ur feedback.
-regards
dhana
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

LocalDataAccess extends Data implements DataInterface


why did you do that? It looked so good before.

Incase of ClientFactory class i have a method getConnection(String mode), Because if the mode is remoteClient then i do a Naming.lookUp() and return the DataInterface to the caller where it will be typecasted as RemoteDataAccess.


I think the key word in your Factory class is par tof it's name. "Client" client to me says nothing about connections. Now remote does. No don't change the name of the class. Make the method called getDataAccess. Because what it returns is an instance of a class that implements DataAccess interface.
This is even though the ClientFactory could possibly do a naming.lookup() call.
Mark
 
dhana sekar
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,
As usual ur right. Now iam clear LocalDataImpl only implements the DataInterface .
Here in the LocalDataImpl class iam just instanciating the Data's object in the constructor. And using it to invoke the method's of the Data class. Is it ok.
thanks & regards,
-dhana
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Here in the LocalDataImpl class iam just instanciating the Data's object in the constructor. And using it to invoke the method's of the Data class. Is it ok.


Yes.
Mark
 
dhana sekar
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,

Hope u might have had a great weekend.

I was bit confused with my design. Here the main purpose of having the LocalDataAccess class is to make use of the Factory Pattern in the
clientside to select the clientMode(Remote or Local). Now i have plans to change the design as follows. Kindly please go through this and give me valuable feedback.

* DataInterface which has all the public method of Data class. This also extends Remote interface of java.rmi.
* I have a RemoteImplementation class RemoteDataImpl which extends UnicastRemoteObject and implements DataInterface.
* I have DataAccessImpl.class which extends Data and have the implementation of lock()
unlock() ceriteriaFind() of Data class. ie iam using the Data.class as it is with out doing any change. Here DataAccessImpl implements DataInterface( this has one or two method like modifyRec(RecNo,seat) which is not there in the Data class which will be usefull for me in case of modifying the record.

awaiting for ur feedback.
thanks & regards.
-rameshkumar.
 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi!
i didn't start my design yet because of one problem. pls. go through that.
topic heading is
"instruction - writing Data Client. "WAITING FOR RESPONSE"
written by Bhuvan.
pleas give my your opinion.
thanks and regards,
Bhuvan.
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

this has one or two method like modifyRec(RecNo,seat) which is not there in the Data class which will be usefull for me in case of modifying the record


If like it. I would remove the modifyRec. The only reason, is later on on the client side you can create a DataAccessFacade, this facade has only a couple of methods. Like bookSeats, or searchFlights. In these methods you can use an object that implements DataAccess, that you use. You could even include your modifyRec method as a private method of this Facade, and use it.
The Facade pattern hides the complexity of a system, like the server from the client. Then the client doesn't need to know anything about the Server or the Data classes. It just knows, Hey I want to book a seat and I have a class that is a facade that I can call one method on, and it will do it for me, and I can trust that it works, and It is nice and neat and clean.
Mark
 
dhana sekar
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark ur right and i agree with the design change u advised. I have the following reasons
why i have bookSeat() and findFlight() in the DataInterface.
1. I have plans to implement Adapter pattern and Factory Pattern in my design. To achive this i have a common Interface(DataInterface) for both serverImpl and
localImpl.
2. I dont want to change the Data.java so
iam extending Data.java in my DataAccess.java and also implementing DataInterface. Here i should have reason for implementing the DataInterface while also extending Data class thats why i have bookSeat(), findFlight() in the DataInterface.

If i go for facade pattern then i think i cant use Factory pattern(iam not sure).
So please guide like which one is best. waiting for ur reply.
thanks & regards
dhana
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

If i go for facade pattern then i think i cant use Factory pattern(iam not sure).


Yes you can. The constructor for the Facade takes an instance of DataAccess, the interface. This way you have a factory that creates a remote or local instance and then passes that into the Facades constructor and the Factory returns the Facade. The factory makes all this for you. That's why they call it a factory.
Mark
 
dhana sekar
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark ,
Following is my understanding about what u said above. Please go throught that and correct me if iam wrong.
* Using DataAccessFactory i will get an instance of the DataInterface.
* There will a AccessFacade which will have a constructor that takes DataInterface as an
argument. Here in AccessFacade there are two methods BookSeat() flightSearch() which intern uses the DataInterface's methods(like getRecord(),modify() etc..) to book the seat and search the Flight info.

thanks & regards,
-dhana
 
dhana sekar
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,

I have one more thing to get cleared. As per the current desing changes.
* The DataInterface will contain only the methods of Data class. If this is the condition then mark i have a doubt that in the DataAccessImp.java( Which extends Data.java, Has the functionality of lock,unlock,criteiriaFind) what is the need of implementing the DataInterface.java which has the methods of Data class, With out implementing this i can't use the Factory pattern in case of mode(local, remote) selection. That's why i plan to have BookSeat(), flightSearch() in the DataInterface. Now iam in a bit confusion so Mark help me to proceed further.
thanks & regards,
dhana
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, if you have a model like this
DataAccess interface has all public methods of Data class, methods throw Exception, it extends Remote.
DataAccessRemote extends UnicastRemoteObject implements DataAccess, Unreferenced. Unreferenced is an interface for handling stale clients. Methods Throw RemoteException and sometimes DatabaseException
DataAccessLocal implements DataAccess. Methods throw Exception, or DatabaseException.
DataAccessFactory has two overloaded methods called getAccess. One takes a host string(remote) the other nothing(local). In mine it just returns DataAccess.
In my main class I call the factory get the DataAccess, create an instance of the Facade passing it the DataAccess class(which might be Remote or Local, it doesn't matter.)
Now I am off and running with my Facade.
Hope that clears things up for you.
Mark
 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Mark,

Iam highly impressed with the above design. But have some issues to be discussed
Mark in the above design DataAccessLocal.java implements DataAccess. As per the above design i have to instantiate the Data class and call the appropriate methods and i have to fill the functionally for lock(), unlock(), cretriafind() in the Data.java. Instred of this if i extend Data.java in DataAccessLocal.java i can provide the implementation for lock(), unlock(), cretriaFind() in the DataAccessLock.java itself where i wont touch the Data.java. But If i do the above then there is no need for me to implement DataAccess interface because this has only the method's of Data.java. If i dont do this i cant make use of factory pattern. So to solve these problems can i introduce some new methods like bookSeat(), flightFind() in the DataInterface
and i can give a reason for implementing DataAccess while extending Data.java and also i can use Factory, Adapter,facade patterns. I need ur comments on this design changes.
thanks & regards,
-rameshkumar
 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ramesh:
I know what you are worrying about. To solve your problem of not being able to use factory pattern, simply changes the signature of Data into "implements DataAcess". Then, both DataAccessLocal(indirectly, by extending Data) and DataAccessRemote(directly) implements DataAccess. So, you can use factory pattern.
Laudney
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic