aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes What To Do If I Don't Like Interface Given To Me? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "What To Do If I Don Watch "What To Do If I Don New topic
Author

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

Anthony Watson
Ranch Hand

Joined: Sep 25, 2003
Posts: 327
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

Joined: Aug 27, 2003
Posts: 1064
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

Joined: Sep 25, 2003
Posts: 327
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

Joined: Aug 27, 2003
Posts: 1064
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).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What To Do If I Don't Like Interface Given To Me?