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

Who Should Handle Locking&Unlocking ;Server/Client

 
Imed Ahras
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys ;
i am stuck to make this decision any help would be grateful!
i am thinking that the client should itself lock and unlock, cause in the requirement they said a client makes the sequence lock, read, modify, unlock. but in this case i need to worry about clients who leave records unlocked,=> extra work needed.
but if the server is handling lock/unlock, it looks alright to me, easy to implement.
Any Advice on which one i should go for!
------
 
John Lee
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lock/unlock are part of data class. In my assignment, client handle lock/unlock, but the locking state of all records are kept in a array, which is stored on server.
 
Imed Ahras
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You went for the client choice,
But don't you need to handle the case where clients who leave without unlocking, using either timers, or implment the unreference interface, or you don't bother with it.
also i think you need to set the server to check that every client who wants to do 'write or modification' operation has to acquire a lock first.
but why haven't you chosen the server to do the locking itself rather than trusting clients and letting them call the lock/unlock methods?
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Imed Ahras:
But don't you need to handle the case where clients who leave without unlocking, using either timers, or implment the unreference interface, or you don't bother with it.
You don't need to. If you really want to, and if it's really easy, you can do it. Do not complicate your design for it though.
but why haven't you chosen the server to do the locking itself rather than trusting clients and letting them call the lock/unlock methods?
The requirement that you must have a client-side class implementing the public methods of Data has subtle implications for your design. If you would handle locking at the server side, then the server exposes a business interface rather than a database interface --- and if your server exposes a business interface, you have no use whatsoever for a client-side Data-like class; in fact, such a class would be very bad OO design. So apparently, this is not the type of design you're being nudged into.
- Peter
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic