[Newbies] Best practice for very simple objects

Norbert Hartl norbert at hartl.name
Tue Jun 26 13:54:19 UTC 2007


On Tue, 2007-06-26 at 15:45 +0200, Michael Rueger wrote:
> Norbert Hartl wrote:
> 
> > At first I created a lot of classes like AdminRole,
> > MemberRole, CreatePermission, ModifyPermission etc.
> > I used the class objects for this. These only carry
> > some state like index, label. The role objects also 
> > carry a set of permissions. 
> 
> I'm a big fan of instances :-)
> 
me too (in general) :)
> Have one Permission class, one for Role etc.
> 
> Then you can have instance creation methods (maybe via a cache)
> 
> Permission modify, Role admin
> 
Yes, this looks very good. So it seems to be all I wanted to have. 
No class use, shared instances and readable usage. Thanks very
much. 

> Internally you could actually use (symbol) names
> 
> Permission>>modify
> 
> ^Permission new name: #modify
> 
> or
> 
> self cache at: #modify ifAbsentPut: [...]
> 
I like this one. Without any reason to mention. I think I'll like
to use == ;)
> This would make it easier to extend the role and permission model later
> 
> Permission>>named: permissionID
> 
> 
> > anAction requires: Modifypermission
> 
> anAction requires: Permission modify

perfect. thanks again,

Norbert



More information about the Beginners mailing list