This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Hi I have a question regarding using a method of LockManger in DataManager my design is pretty much same as that described in Andrews book and follow the facade pattern for the Data class that implements the DBAccess interface. So Data class calls methods of DataManager class(all read/write/find methods) and LockManager (lock, unlock) methods
My question is can I call LockManager method within methods of DataManager eg update, delete etc? is it against the principle of separation of classes?
pseudocode:
class DataManager{ public void updateRecord(data, recno, cookie)throws securityexception, rnf { if(LockManager.isLockedBy(recno,cookie)) throw new securityexception(); //continue update record
}
class LockMananger { map of locked records; lock method returns cookie; unlock method; isLockedBy method return boolean;
} [ April 17, 2008: Message edited by: Mary John ]
SCJP 5.0<br />SCJD working on it
Eric Ushie
Ranch Hand
Joined: Dec 01, 2005
Posts: 31
posted
0
Hi Mary,
With reference to Andrew's book, i think you can call methods of LockManager from your DataManager given your scenario without breaking any rule.
Jimmy Ho
Ranch Hand
Joined: Jul 31, 2007
Posts: 56
posted
0
Quick question: Which book is "Andrew's book"? Can someone give the title and author? Thanks.
Well actually the author is Andrew... Andrew Monkhouse and Terry Camerlengo and the name of the book is "SCJD Exam with J2SE 5 (2nd Edition)".
Good luck!
Cristian Aionesa
Greenhorn
Joined: Jan 05, 2007
Posts: 18
posted
0
Mary John wrote:Hi
I have a question regarding using a method of LockManger in DataManager
my design is pretty much same as that described in Andrews book and follow the facade pattern for the Data class that implements the DBAccess interface.
So Data class calls methods of DataManager class(all read/write/find methods) and LockManager (lock, unlock) methods
My question is can I call LockManager method within methods of DataManager eg update, delete etc? is it against the principle of separation of classes?
pseudocode:
class DataManager{
public void updateRecord(data, recno, cookie)throws securityexception, rnf
{
if(LockManager.isLockedBy(recno,cookie))
throw new securityexception();
//continue update record
}
class LockMananger
{
map of locked records;
lock method returns cookie;
unlock method;
isLockedBy method return boolean;
}
[ April 17, 2008: Message edited by: Mary John ]
Hi Mary John,
I have the same problem as you did. How did you handle it? The solution that you gave is the only one that I can think of, but this make my classes depend of one another...or not?! If I reconsider my thoughts the fact that one class uses the services from another is not a bad thing. I'll probably follow your design.
What do you guys say about that? Any advice? Thanks.