Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: about lock cookie

 
Bigwood Liu
Ranch Hand
Posts: 240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
My DBAccess interface have two lock concerning methods:

Because the lock/unlock is consided only in network mode, I think the lock and unlock methods should be only implemented in RemoteData class, the Data class should only have empty lock/unlock methods like a WindowAdapter, am I right? thus there is a question: what should the lockRecord return, 0?
In network mode, I want to use the combination of the time when the record is locked and the record number as the cookie, thus the cookie is unique.
Waiting for your comment
Regards,
Tom
 
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 Damu,
Because the lock/unlock is consided only in network mode ...

Why is the lock/unlock only considered in network mode?
Or, why can't you use lock/unlock in standalone mode?
Regards, Andrew
 
Bigwood Liu
Ranch Hand
Posts: 240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey Andrew,
Thank you for your reply first, I think in standalone mode there is only one user use the computer at any time, so there is not multi thread problem, so the lock issue is unnecessary.
Regards,
Tom
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi damu,

In network mode, I want to use the combination of the time when the record is locked and the record number as the cookie, thus the cookie is unique.

System.currentTimeMillis() is not precise enough to make sure your cookie is unique. But, BTW your lock cookie does not need to be unique : just difficult to guess by a malicious coder. Think of Random.nextLong().

Because the lock/unlock is consided only in network mode, I think the lock and unlock methods should be only implemented in RemoteData class, the Data class should only have empty lock/unlock methods like a WindowAdapter, am I right? thus there is a question: what should the lockRecord return, 0?

I agree with Andrew. Your design will be simpler if you keep locking for local access.
Best,
Phil.
 
Bigwood Liu
Ranch Hand
Posts: 240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Philippe ,
Thank you for reply.
since you implement the lock/unlock in data class, will you use it in standalone mode? But I think it is unnecessary.
Regards,
Damu
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi damu,
You're right, it's "unnecessary", but IMO, if you do, the benefits are that it's simpler to implement and simpler to maintain, actually at no cost (if there are no other clients competing for locks, locks are granted immediately in any case).
Best,
Phil.
 
Bigwood Liu
Ranch Hand
Posts: 240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Philippe ,
Yes, I see, you are right, thank you
Regards,
Damu
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic