Replace Whole Object Through Object Method

Maric Michaud maric at aristote.info
Mon Jun 26 21:01:19 EDT 2006


Le lundi 26 juin 2006 22:37, digitalorganics at gmail.com a écrit :
> Won't work because there will be employers that aren't workers.
> And yes, only some workers will become employers, but also only some
> employers will also be workers (at some point in program). Let me be
> more clear:
>
> workers
> --> subset of workers --become--> employers
> employers
> --> subset of employers --become--> workers
>
> It is very important that both should maintain attribute values,
> regardless of whether they take on new "roles". Furthermore, this is a
> very simple case and ultimately in my program an object should be able
> to dynamically take on a multitude of roles (classes of behavior)
> without mucking at all with their pre-existing states.

This seem to be a OO design problem and you clearly make a misuse of 
inheritance, if a person can eventually have many roles, but doesn't have 
this role for all his lifetime, then the person *is* not his roles.
That the meaning of inheritance, class B(A) means a B is a A.
The association between a person and his roles is obviously a 1-n association, 
which can be rendered by different patterns (delegation, composition, 
strategy, etc.).
You should google on "design patterns" and make your choice.

-- 
_____________

Maric Michaud
_____________

Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097



More information about the Python-list mailing list