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

Design Question Mark

Samual Harvey
Ranch Hand

Joined: Aug 06, 2002
Posts: 119
Mark,
I am currently working on the design. Going thru ur design in some of the past discussions I have seen that you have created DataAccessFacade and DataAccessFactory classes. I was wondering if these two could be combined into one class called DataAccessManager which contains all the methods of DataAccessFacade and can also determine whether the connection requested in local or remote. Is this to keep the client unware of whether the connection is local/remote? Can you explain why you kept them in two separate classes?
Also your DataAccessLocal and DataAccessRemote classes implement DataAccess Interface. I am thinking that in this case the DataAccess Interface is a public interface and the diff between Local and Remote class is that Remote class methods throw the remoteException.
Does ur DataAccess extends Remote class? If not then why you created DataAccessRemote class. How ur DataAccessRemote class has access to the Remote Server?
Did you also created a remote interface like the ServerInterface and its implementor class ServerInterfaceImpl to handle the rmi calls.
[ August 06, 2002: Message edited by: Samual Harvey ]

Samual Harvey<br />SCJP2<br />SCJD2
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Samual,
I can't speak for Mark, but the reason you have both is that the Factory is on the server and the Facade is on the client. The Facade hides the particulars of database operations from the rest of the client. In my design, it was the only class on the client that knew anything about the DataAccess interface. I personally only had one interface for both local and remote. My DataAccess extended Remote and public Data methods were all tagged to throw RemoteException.
When in local mode though, no RemoteException could be thrown. So my DataFacade had no idea whether it was accessing a database locally or remotely; all calls were identical for either mode. The only redundancy was the call to read for booking in local mode. Lock and unlock were no-ops in the local DataAccess object.
Hope this helps,
Michael Morris


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937

I was wondering if these two could be combined into one class called DataAccessManager which contains all the methods of DataAccessFacade and can also determine whether the connection requested in local or remote.

Mark is in Bangladesh on a mission, but I think he would say something like this:
"Well, I want to be a math teacher, but if I were a CS teacher, I would stress that the first OO principle is to give each class a narrow, highly focused set of responsibilities. The factory is a creational pattern and the facade is a structural pattern, so don't mix the two, instead use a combination".
Eugene.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Well, I want to be a math teacher, but if I were a CS teacher, I would stress that the first OO principle is to give each class a narrow, highly focused set of responsibilities. The factory is a creational pattern and the facade is a structural pattern, so don't mix the two, instead use a combination
Mark
wow. Eugene has read my mind.


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

Joined: Aug 06, 2002
Posts: 119
The question is do we need that level of abstraction for this assignment. The reason I'm thinking like this is because:-
1. If we run the client with command line localhost parameter then the client knows if it is local/remote.
2. Once the client finds out local/remote, it has to run the data class methods. The DataConnectionManager can reside on the client and can perform the task of ; in case of local it can create data object directly and for remote it can do a lookup using the localhost, get the reference and invoke the methods on the server using the server reference. So you may not need a Factory class on the server side.
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937

1. If we run the client with command line localhost parameter then the client knows if it is local/remote.

I don't like how you use the word "localhost" in this context. You are implying that if the client is started with a "localhost" parameter, it is a local connection, but in fact localhost is the name of the server, and so the client should run in a networked mode. Remember, no sockets should be created in local mode. So just don't use "localhost" as a parameter to indicate non-networked mode, because localhost is a perfectly valid server DNS.

in case of local it can create data object directly and for remote it can do a lookup using the localhost, get the reference... So you may not need a Factory class on the server side.

What you describe above is exactly the job of the factory class, so why do you want to eliminate it? And again, "and for remote it can do a lookup using the localhost" is very misleading.
Eugene.
[ August 06, 2002: Message edited by: Eugene Kononov ]
Samual Harvey
Ranch Hand

Joined: Aug 06, 2002
Posts: 119
No here by localhost I meant the parameter to the client, absence of which means local and presence mean remote.
And by lookup I meant for Naming.lookup(string abc). abc can be //localhost/FBNServer. If start the client as java FBNclient localhost.
Do you have second thoughts for having a remote Interface ServerInterface and its implementor class ServerInterfaceImpl. I think this is required for the Server.
Thanks.
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937

No here by localhost I meant the parameter to the client, absence of which means local and presence mean remote.

Absense of "localhost" parameter means local connection, and presense of "localhost" parameter means remote connection? Forgive me for being blunt, but I were a grader, I would take 50 points away from the score just for this design decision. I strongly suggest that you re-think this. "localhost" is just another name for IP 127.0.0.1, nothing more or less.
Eugene.
Samual Harvey
Ranch Hand

Joined: Aug 06, 2002
Posts: 119
OK that I can understand but can you put your thoughts the question that I still have.
Thanks.
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937

OK that I can understand but can you put your thoughts the question that I still have.

The client can use a factory class to get access to a data object that represents a local or a remote connection. The facade simplifies access to some functionality and what you put in it depends on your design. In my case, the facade class (which I called DataService) used a data object returned from the factory to implement methods such as searchFlights(), bookFlights(), etc. Your design might be different, but as long as it is clear, well documented, and is easy to extend/maintain/defend, you will do just fine.
Eugene.
[ August 07, 2002: Message edited by: Eugene Kononov ]
Samual Harvey
Ranch Hand

Joined: Aug 06, 2002
Posts: 119
I think this is what I need to determine now: -
Did you also created a second interface like the ServerInterface and its implementor class ServerInterfaceImpl for the Server. Or did you have just one interface.
If you have just one interface did your main server starting class used DataAccessRemote class or it used a ServerInterfaceImpl class(in this case it can be another implementor of the first interface).
Thanks.
Ashik Uzzaman
Ranch Hand

Joined: Jul 05, 2001
Posts: 2370


Mark is in Bangladesh on a mission, but I think he would say something like this:
"Well, I want to be a math teacher, but if I were a CS teacher, I would stress that the first OO principle is to give each class a narrow, highly focused set of responsibilities. The factory is a creational pattern and the facade is a structural pattern, so don't mix the two, instead use a combination".

Dear Mark, are you in Bangladesh till now? If yes, probably you are within a kilometer or two from my house and office in Dhaka. I would be glad to invite you to a tea-java session. I, like all others here, watch your posts with interest. How many days are you staying here?
If you don't have to keep secret, would you like to focus on your mission in Bagnladesh?
Regards,
[ October 19, 2002: Message edited by: Ashik uzzaman ]

Ashik Uzzaman
Senior Member of Technical Staff, Salesforce.com, San Francisco, CA, USA.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

I'm sorry. I am not in Bangladesh, I was however in Switzerland at about that time.
You see Eugene likes to send me(jokingly) to foreign lands. Sometimes recently I haven't ahd as much time to post as I'd like, so that's when Eugene puts me to an exotic far away place.
But thank you very much for the invitation, if I was there I would be there for tea.
Mark
Kruger Scheitz
Ranch Hand

Joined: Jul 31, 2002
Posts: 72
Mark and Morris, are u saying the DataFacade class here has all the methods that contain a reference to DataAccess, eg. bookflight(), searchflight and etc....
And is this the class that implements Observable ?
Kruger Scheitz
Ranch Hand

Joined: Jul 31, 2002
Posts: 72
Mark and Morris, i'm confused with declaration of throwing DatabaseException and RemoteException in the DataAccess. Do i need to declare them in DataAcess or declare them only when it's implemented in the Local Data or Remote Data.
i have a DataInterface and DataRemoteInterface
and pls enlighten me with DataFacade class. Is this the class that contain all bookFlight() and searchFlight()? if so, does it implements Observable ?? pls help
Kruger Scheitz
Ranch Hand

Joined: Jul 31, 2002
Posts: 72
If i ever declare the DatabaseException and RemoteException in the DataInterface ( in ur case is DataAccess ), i ll need to implement those methods that throws RemoteException as well in LocalData since LocalData implements DataInterface. It really does not make sense LocalData throwing a RemoteException...Any solution for this ?
Kruger Scheitz
Ranch Hand

Joined: Jul 31, 2002
Posts: 72
how do u determine which method that throws RemoteException and which method that doesn't in the DataInterface ( DataAccess ) ? what is the thumb of rule?
please enlighten me all the question on those posts b4 this too.. =)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Design Question Mark