Hi,
I wanna discuss something about general Action-Role section of the security module. Normally I use to make data tables in database for Actions, Roles and Action-Role mapping for the security module of the project.
Actions like- CanReadMail, CanReplyMail, CanForwardMail etc...
Roles like- Trainer, Agent, Supervisor, Manager etc...
A role may have multiple actions like- an Agent can ReadMail as well as can ReplyMail.
This is how I was doing it so far...but now what we r trying to do is we r trying to implement Factory pattern for this as...
//Product //Creator
interface IAction abstract class Role
{ {
} List lstActions;
//constructor
Role() { AddActions(); }
//Concrete Product
class CanReadMail : IAction //virtual function
{ virtual AddActions();
} }
class CanReplyMail : IAction //Concrete Creator
{ class Trainer : Role
} {
override AddActions()
class CanForwardMail : IAction {
{ lstActions.Add(new CanReadMail());
} }
}
class Agent : Role
{
override AddActions()
{
lstActions.Add(new CanReadMail());
lstActions.Add(new CanReplyMail());
}
}
class Supervisor : Role
{
override AddActions()
{
lstActions.Add(new CanReadMail());
lstActions.Add(new CanForwardMail());
}
}
As Actions and Roles are not going to be changed more or less. I mean right now it's said that current solution's requirement is only this much of roles and actions. But as we all know in software industry change in customer requirement is always expected-may be in 6 months or a year or 2.
So my query is,will it be a good approach to go for class representation (Factory Pattern) of the Actions and Roles in this case or database approach will be much better.
One more thing, I am unable to find a good practical approach to implement Factory Pattern. If somebody can help me out with some good example.
Thanx a lot for going through my query. Ur suggestions are precious for me.
Regards
Hazara Singh
Start Free Trial