Win a copy of Android Programming: The Big Nerd Ranch Guide this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

isLocked method implementation  RSS feed

 
jesal dosa
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am doing the final piece of the puzzle, the locking bit. I have been looking through some posts about the locking methodology, and i have come up with the following bit of code. What i dont understand is why do I need the isLocked method. When i am doing a booking i do the

lock
do the booking
unlock

i could use the isLocked method in the lock method to test the while condition. I have read a post which suggest the islocked in not required but rmandantory because its in the interface.



I just want to confirm the isLocked method is fine and not required apart from implementing suns interface
 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi the isLock() method is required to implement cos it's part the interface. However, it's not necessary to use it. But it can be called inside your update/delete to ensure that record is locked before doing the actual update/delete.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Posts: 12105
246
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jesal

Please take the time to read the JavaRanch SCJD FAQ, particularly the section on our policy on questions on the exam / details of how to do the assignment.

I agree with K Tsang that this method must be implemented, but need not be used. Slightly off topic - Ken Schwarber presented a talk on Scrum at Google, and towards the end of it (if I remember correctly) he talks about one of the typical problems with Waterfall, namely that because it becomes so difficult to introduce a change in the project 6 months after it is started, people tend to put into the requirements documents every possible thing they can think of, even if it has little value. In that respect, the instructions from Sun are very typical - they often contain instructions that have little or no value. And some of these are included deliberately just so that the developer has to make a design decision.

Regards, Andrew
 
jesal dosa
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks K. Tsang and Andrew,

this clears it up. Sorry for the initial incorrect posting.

King Regards

Jesal
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!