Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What To Do If I Don't Like Interface Given To Me?

 
Anthony Watson
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The database interface that Sun provided in my assignment has an update method with the following signature:

public void updateRecord(long recNo, String[] data, long lockCookie)
throws RecordNotFoundException, SecurityException


I want to implement locking like this: lock record, see if it has changed, update record, unlock record

However, in order to see if the record has changed since the user last refreshed his view, I need the client to pass his view of the record in addition to his changes to the record. The above interface does not allow for the client view of the record to be passed to the updateRecordMethod. How should I approach this? Should I provide an empty implementation of the method? Should I label it as deprecated and suggest using a method such as updateRecordSafe instead? Thanks all.
 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Anthony Watson:
Should I provide an empty implementation of the method? Should I label it as deprecated and suggest using a method such as updateRecordSafe instead?


Antony,
Both the above options are risky.

My instructions say that the functionality of the update() method is to modify the fields of the record in the database only, if the cookie supplied is the cookie that was used to lock the record before.

Which means that when the update() method is called, the record is already in a locked state by the client.

Probably your instructions also may mean the same thing.


"lock record, see if it has changed, update record, unlock record"...
- could be the list of methods called in the booking use case and
not for the update() method in the Data() class. So I would say....

for the booking use case:

"read client record, lock record, see if it has changed, update record, unlock record."


for the update() method in the Data() class:
"do recNo validation, do cookie validation, update the record."
 
Anthony Watson
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm retarded...I asked my questions as though the client was going to call the update method directly. Obviously, the client should go through some sort of adapter that encapsulates all the read, lock, update, unlock functionality.
 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Anthony Watson:
I asked my questions as though the client was going to call the update method directly. Obviously, the client should go through some sort of adapter that encapsulates all the read, lock, update, unlock functionality.


Yes. You also have an option of implementing it either on the client side(2-tier approach) or server side(3-tier approach).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic