
Originally Posted by
seratonin
Alright, I'm with ya. We can keep the data model with a many-to-many in order to avoid rundundant storage, but in the object model we will have a one-to-many. Can we weed out duplicates in the Mapper classes? dagfinn, how would you change the proposed domain model to accommodate this?
JT
Well, I relalize I haven't thought this through yet. I'm learning something. What I'm asking myself is what kind of object a permission is. Is it a value object or a reference object? (I'm using Fowler's naming; Evans talks about value objects and entities.) In fact, is there a pressing reason why a permission should be represented as an object at all?
Does the list of permissions need to be stored in the database? There may be something I've missed, but from what I've seen so far in this thread , permission 'do_stuff' has no real meaning unless it's named expicitly in code to choose a path of action depending on the current user's authorization. So why would you need to create a new permission except when you're adding new authorization code? If you have to change code anyway, perhaps the entire set of permissions might as well be hard coded? So taking the the setUp test code we might change this:
PHP Code:
$edit->addPermission('do_stuff');
$edit->permit('pleb', 'do_stuff');
To this:
PHP Code:
$edit->permit('pleb', PERM_DO_STUFF);
Or, using methods as "class constants" in PHP 4;
PHP Code:
$edit->permit('pleb', Permission::DO_STUFF());
// Permission class:
class Permission {
function DO_STUFF { return 0; }
function DO_OTHER_STUFF { return 1; }
// etc.
The database schema could be the same, only with the permissions table removed.
Bookmarks