public void updateRecord(final long recNo, final String data) throws RecordNotFoundException, SecurityException;
and my Data class implements the DBReader interface and indirectly implements DBAccess . Now deleteRecord and updateRecord are overloaded methods in Data class and clients must invoke the new methods in order to delete or update the record. I have chosen this strategy to build locking functionality at server side and fulfil my Cookie requirement.
my update method in Data class looks like the following
similarly i have delete method also.
Does my design look fine or Do I need to consider alternative way?
I don't think creating an extra method just to group a call to lock, update and unlock is a good idea. I guess to book a room you make a call to your custom updateRecord? And I think you are missing one vital point here! My booking business logic goes as follows:
check if room is already booked
if it is throw exception (don't allow 2 customers to book same room twice)
if it is not update record with customer id
So it seems you don't care about the check to see if a room is already booked, which would mean that 2-3-4 customers each can book that same room in the same hotel and be all present that evening at reception to claim they have a valid booking of their room
If your operation flow is similar to the one i suggested, your method name updateRecord is wrong! because checking if a room/contractor is still available is only a check you have to do with booking this room/contractor. Not when changing its size for example. So you have to rename it and you won't have an overloaded method.
Another point against your approach, maybe even bigger than the 1st one: the data class (and sun's interface) are very general. you could read/write with that class also customers instead of rooms/contractors. So adding specific business logic for updating a contractor record to the general data class would be a poor design decision in my opinion