Design Patter Question
I have a generic Lock entity which Locks a record in the database.
It contains a generic method called
LockRecord(objectType,objectInstance)
I have different objects implementing the lock, which do you is better?
1.
Object1 class
LockObject1(object1instance)
{
//do necessary stuffs for object1instance
Lock.LockRecord(objectType.Object1,object1instance )
}
Object2 class
LockObject2(object2instance)
{
//do necessary stuffs for object2instance
Lock.LockRecord(objectType.Object2,object2instance )
}
or
2. at the LockRecord method i will have the following:
LockRecord(objectType,objectInstance)
{
switch(objectType)
{
case objectType.object1 : do object1 stuff;break;
case objectType.object2 : do object2 stuff;break;
.
.
.
}
}
I think option 1 is better because of loose coupling. Do you guys heve a better way of implementing this?
"Dont you ever give up!"
__________________
\"Dont you ever give up!\"
|