• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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

 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
We should throw him a surprise party. It will cheer him up. We can use this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic