• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Data.update()/delete() - should they call isLocked() ?

 
Gytis Jakutonis
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Data.update()/delete() - should they call isLocked() ? Since requirements state, that "lock() Locks a record so that it can only be updated or deleted by this client". Code, which uses Data will definitely follow sequence of lock() update() unlock(), so IMO there is no need to test isLock() in update(). Is this assumption correct? Any comments? Thanks.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gytis,
You are making some big assumptions here:
  • Only your code will ever connect to your database.
    I think the instructions hint that the company is already planning on rewriting the application in the near future. I would not be surprised if they decided to keep a working server while redeveloping the front end. So this should not be an expectation on your part.
  • All code that connects to your database will always follow your logic and always give you valid data.
    This is a dangerous assumption to make - some other programmer may miss the fact that they need to lock the records (many people in this forum keep asking why they need to do locking ). So you should test to see whether a method that modifies code is being called by the client who owns the lock.


  • Note that last bit though: "you should test to see whether a method that modifies code is being called by the client who owns the lock". It is not enough to check that the method is called while the record is locked, your instructions require you to check whether the owner of the lock is the one calling the method.
    So you may find that calling isLockec() man not help you within the update() or delete() methods - you may have to call some other method.
    Regards, Andrew
     
    Gytis Jakutonis
    Ranch Hand
    Posts: 76
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Andrew,
    thanks for replay. Now I'm sure that I need to chek isLocked() . Since I'm using Data per client approach, I will probably use isLocked().
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic