Question - Strategy Design Pattern
Following is the structure of my class
What is required:
1. Container will keep both types of users
2. SpecialUser will have the functionality of add permissions - Done
3. Normal User will not be allowed add permissions - Done
I have chosen strategy pattern to achieve above
The thing I am not able to achieve is
4. Both Types of users will be hydrated from the Database (The users will be initialized with list of default permissions)
Am I right in choosing this pattern in this situation? If yes then how do I address requirement 4?
A Solvent, Dec 28, 2011
Your selection is correct.
When you're populating the users in Container from database, do you've any option to segregate the user type? If you, at the time of populating the users collection, based on the user type, you can create the relevant object and then while looping thru the users collection, the relevant object's method will be called.
Sivakumar Sivaprakasam, Jan 05, 2012