• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what design patterns?

 
Akash Singh
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am still doing the Old FBN Assignment, and writing design document.
I have one class DataClient that has all the methods of the Data class
however, actual implementation is in Data Class that is accessed through
DataAdapter Class(for Local Mode) , and in RemoteDataImpl
( for locking only and in network mode) for all other methods it relies on
Data class that is accessed through DataAdatper.
Inaddition to all public method of the Data class, DataClient also has two static method getLocalDataCleint and getRemoteDataClient.
Both these methods return DataInterface -- in case of local connection, it
returns instance of DataAdapter -- in case of network connection , it returns instance of RMI object(RemoteDataImpl). RemoteData extends DataInterface, and DataAdapter implements LocalDataInterface(subinterface of DataInterface).

Am i write, If i say DataClient is based on Factory Method Pattern ?
Am i write, If i say DataClient is based on Proxy Pattern ?
Am i write, If i say DataClient is based on Adapter Pattern ?

Regards,
Akash Singh
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Akash,
Just to clarify what your DataClient does / provides, I assume you are using code such as:

Where you could easily swap the call to getLocalDataClient() with getRemoteDataClient()?
This sounds like a factory to me. In addition, it can also be considered a proxy.
I would not normally consider this an Adapter - you are maintaining the same interface throughout. You are not adapting one class to fit the requirements of a different interface.
Regards, Andrew
 
Akash Singh
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks again Andrew.

Where you could easily swap the call to getLocalDataClient() with getRemoteDataClient()?
Yes, you are right. I have above said implementation.
I am not clear why is this class based on "Proxy" pattern.
Is this beacase factory method returns DataClient, actual implmentation of the methods are implemented in some other classes(Data and RemoteDataImpl), although DataClient class has all the method of the Data.
Regards,
Akash
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Akash,
A proxy class is one which stands in for another class. In this case, your DataClient class is standing in for either the DataAdapter or RemoteDataImpl (not sure if I got your class names right). That is, you are calling methods on the instance of DataAdapter rather than calling methods on the returned class.
Factories do not need to use the Proxy pattern, but for this assignment it is probably better to do so, as that way your proxy can handle the networking errors for you, making the client code less network centric.
Regards, Andrew
 
Akash Singh
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Andrew.
Regards,
Akash
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic