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

NX: (B&S Contractors) Encapsulation Design Issues.

 
Raj Shekhar
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I started my assignment with the data base implementation. So far I completed the 'DBAccess' interface and the corresponding 'Data' class. The DBAccess has methods for locking, unlocking in addition to other db functions and their signtaure is provided by SUN and I do not want to change it. Hence, the client GUI will have to call the functions in the following order to ensure thread safety.
lock
db function(e.g. add)
unlock.
However, I do not like the idea of making the lock, and unlock as public methods and also do not want to assume that client will follow this protocol. I want to provide an additional variation (or layer) of the interface where I would provide db functions that will take care of locking. I also created a class for handing a single record. I would also like to provide further encapsulation in this layer so that I can handle a 'record' object instead instead of String[] which is required in the signature of DBAccess methods.
However, since I am a novice at OOD, I am not sure what is the best approach for this. Presently my idea is to provide the following:
a. New Interface BetterDBAccess(no relation to the DBAccess)
b. New Class BetterDBAccessImpl which implements the new interface
c. The BetterDBAccessImpl class will 'contain' a object of the 'Data' class and will provide methods which will take care of threads and additional encapsulation.
I would like to know if this the right approach, potential pitfalls and if there is a better way of doing this.
Thanks for you help.
Raj
 
George Marinkovich
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Raj,
It sounds like you're exactly on the right track. What you're suggesting in a, b, and c, is an implementation of the object adapter design pattern, wherein you are adapting the BetterDBAccess interface to the Sun-supplied DBAccess interface (as implemented by the Data class). This is definitely along the lines of what many others on the forum have done. Something to consider while you are designing the BetterDBAccess interface is your network communications solution. If you go with the RMI solution, then that has some implications for how you should design your BetterDBAccess interface.
Hope this helps,
George
[ February 05, 2004: Message edited by: George Marinkovich ]
 
Raj Shekhar
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks George. Since, I do not have much experience with OOD, it is reassuring to know that I am on the right track.
Thanks also for the warning regarding the furure implications of a RMI solution.
Raj
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic