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

Remote and Local Database Interface

 
Rudy Yeung
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please feel free to comment if my approach is acceptable:
I create a database interface (DBInterface) containing all the public methods of the data class, each of which throws an Exception. For local database connection, I create a local database interface (LocalDBInterface) that extends DBInterface. This LocalDBInterface have the same list of methods as the DBInterface except it throws more specific exceptions like IOException and DatabaseException. I also create a remote database interface (RemoteDBInterface) that extends DBInterface. This RemoteDBInterface have the same list of methods as the DBInterface except it throws more specific exceptions like RemoteException, which is for RMI.
In my coding, I have a lot of places throwing the general exception, i.e. Exception whenever calling the data class method is required. Using this approach, I do not need to duplicate the effort of coding the remote data access which is identical to the data class implementation.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic