This is my implementation of lock/unlock. I implemented lock/unlock in Data by using a reference of LockManager. I think this is a "generic" functionality, and it should be here.
I don't have a LocalData, if it is in local mode, I just passed a wrapper class of Data (with business logic such as bookFlight, but without lock-read-modify-unlock sequence). If it is in remote mode, I passed the RemoteDataImpl(I aslo implement bookFlight here, but with the sequence), another Data wrapper. Thanks for your comments. -Kevin
I implemented lock/unlock in Data by using a reference of LockManager. I think this is a "generic" functionality, and it should be here.
Hmm, Data class was generic before you made it use your LockManager. Not anymore, -- if you want to replace your locking schema with something else, your (presumably generic) Data class has to change. So, here is a challenge for you, -- can your app use LockManager while you Data class knows nothing about it? Eugene.
Joined: Jun 19, 2002
Eugene- I think the Data class is a reflection of the database(a file here), it should contains all the functinalities that a database needs: insert, delete, locking etc. Having a reference of LockManager won't affect it. But this is just my thought. Actually, my question for this topic are: 1. Whether this implementation is correct? I have seen lots of people having LockManager and Datainterface in RemoteDataImpl, and applying lock schema there. 2. Is this the right place to apply business logic(the wrapper class)? I think it is the argument of fat-server vs. fat-client. Again, thanks for your reponse. -Kevin
Kevin, Think about not having two different wrapper versions of Data for local and remote mode. Assuming that your design decision doesn't include locking in local mode, there is no need for the Data object to interact or know about the LockManager. The sequence below is used by many submissions in this forum: DataImpl -> LockManager -> Data Keep in mind that LockManager doesn't have to implement all the public methods in the Data class. There are lot of things you can do in LockManager including a CleanupThread inner class to remove locks on records locked by dead clients.
Joined: Jun 19, 2002
Sai, Thanks for your advice. After I read some threads from this forum, I convince myself to move the lock schema to RemoteDataImpl and move the business logic to client (Model of MVC). Kevin