Initialize Object based on Role
I have a question on how to initialize an object based on user role.
For example, say, I have an abstract class User. There exist 3 different kinds of user Admin, Member, Moderator,
Every one has it's own set of functionality
How do I initiate an object of a particular type based on user role?
Suppose I have an abstract class User with a property Role which is an Enum.
I would like to code it like this
User user = new User();
u.Role = UserRole.Admin;
then Object user must be decorated with the properties of Admin.
I just want's to know how do I change it?
Here is what I was trying to do... is shown in Code block below
Asmprogs Asmprogs, Oct 09, 2010
Perhaps something similiar to the State pattern would work. However, your question seems contradictory, at least to me, in term of semantics
You mention each kind of user has it's own functionality and then you mention that properties must be set for each type of user. There is a difference on how you would implement this based on which statement is correct. Functionality implies 3 sets of business logic, properties are just that.
p.s. you didn't appear to attach any code.
Chris Bint, Oct 11, 2010