Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Database design problem

 
Garry Kalra
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have completed my design and now i am stuck with two
designs to choose from. Pls help me out in choosing one.
Design 1:-
1) An interface called DatabaseServer declares all the
public methods of the data class and all methods throw
Exception.
2) An interface called RemoteDatabaseServer which extends
DatabaseServer and Remote. All the methods throw the exceptions
declared in Data class in addition to the RemoteException.
3) An interface called LocalDatabaseServer which extends
DatabaseServer. All the methods throw the exceptions
declared in Data class.
4) A class which implements RemoteDatabaseServer and declares
all the public methods of the Data class. All the responsibility
is delegated to a Data class object.
5) The Data class implements LocalDatabaseServer.
The only problem i think is that the exceptions are two Generic.
Design 2:-
1) An interface called DatabaseServer declares all the
public methods of the data class along with the respective
exceptions in addition to the RemoteException.
2) An interface called RemoteDatabaseServer which extends
DatabaseServer and Remote.
3) A class which implements RemoteDatabaseServer and declares
all the public methods of the Data class. All the responsibility
is delegated to a Data class object.
4) The Data class implements DatabaseServer.
As DatabaseServer throws RemoteException, i think this is
not a problem as a method can throw a subset of exceptions
declared in the interface/Superclass
Pls guide which of these designs is most appropriate.
Gaurav Kalra
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your design 1, the client program has to work with a DatabaseServer interface that throws a completely shapeless, meaningless, generic Exception <shudder>. You rightly flag that up as a problem.
- Peter
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic