This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Exceptions Handling 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 "Exceptions Handling" Watch "Exceptions Handling" New topic
Author

Exceptions Handling

Kruger Scheitz
Ranch Hand

Joined: Jul 31, 2002
Posts: 72
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.
how do u determine which method that throws RemoteException and which method that doesn't in the DataInterface ( DataAccess ) ? what is the rule of thumb?
If i ever declare the DatabaseException and RemoteException in the DataInterface ( in ur case is DataAccess ), im forced to implement those methods that throws RemoteException in LocalData since LocalData implements DataInterface. It really does not make sense LocalData throwing a RemoteException...And if this happen, my DataFacade will throw RemoteException as well...how can i make my LocalData that throw DataException only and leave RemoteExceptions thrown in the RemoteData..Any solution for this ?
i have a DataInterface and DataRemoteInteface.
and pls enlighten me with DataFacade class. Is this the class that contain all bookFlight() and searchFlight()? need help badly over here
Thomas Fly
Ranch Hand

Joined: Sep 09, 2002
Posts: 164
All of your public methods in a class that implements the Remote interface have to throw RemoteException (makes sense, doesn't it?) Conversely, if a class does not implement Remote, its methods don't throw RemoteException.
The application really dictates the use of the Model-View-Controller architecture; the high-level classes that implement that structuring I named DataAccess, GUI, and DataPresentation, respectively.
GUI is view-oriented, and doesn't want to know anything about exceptions relating to the model, or communicating with the mode. On the other hand, DataAccess doesn't have any idea of what to do with an exception, except to pass it on down the line.
"The buck stops here" in the controller, which has some knowledge of the model, and some knowledge of the view, and hence the ability to pop up a dialog box saying "Uh-oh! Your Martha Stewart stock just fell through the floor " (or whatever).
In other words, just keep "passing the buck" in your code, until you reach a point where you know how to deal appropriately with the situation.


Fly by Night Consultants<br /> <blockquote><font size="1" face="Verdana, Arial">quote:</font><hr><i>I climbed on the back of a giant albatross<br />which flew through a crack in the cloud<br />to a place where happiness reigned...<br />all year 'round<br />the music played ever so loudly!</i><p><a href="http://thomasfly.com/songs/Traffic/Hole_in_my_Shoe_qt.htm" target="_blank" rel="nofollow">Hole in My Shoe</a><hr></blockquote>
Kruger Scheitz
Ranch Hand

Joined: Jul 31, 2002
Posts: 72
thomas fly u didn't really answer my question. =)
can u be more specific?
Thomas Fly
Ranch Hand

Joined: Sep 09, 2002
Posts: 164
In order to access the database remotely, you basically have to create a "wrapper" class (that ultimately gets turned into a stub that your remote clients use).
Your FBN Data class will throw whatever exceptions it needs or wants to. Those must then must be propagated by the wrapper class which must also throw RemoteException (e.g., "Hey Kruger, your idiot boss just tripped over your network cable and now you've lost your connection to the server").
FBN's data class should know very little about the universe outside of db.db. It shouldn't be concerned with the existence of networks and TCP/IP any more than your GUI class should- though the two are at opposite ends of the totem pole, so to speak.
 
GeeCON Prague 2014
 
subject: Exceptions Handling