2009/11/13 Rickard Öberg <[email protected]>

> On 2009-11-13 15.41, Jacek Sokulski wrote:
>
>> Hello,
>> Some questions on modelling entities:
>> Suppose I have Employee and Manager entities and Manager is Employee
>> with additional behaviour and/or state.
>> 1. Can I promote Employee to Manager? I.e. can I take an Employee object
>> and add to it Manager roles (during runtime, entity creation)?
>> 2. From DB point of view, is a Manager an Employee? e.g. can I construct
>> a query for all Employees that are Managers or Traders?
>> uow.get(Employee.class, <ID>) will it return Manager object or Employee
>> not castable to Manger?
>>
>
> Employee, Manager and Trader are roles, not entities. If you have dynamism
> (i.e. these roles can come and go), then I would suggest having PersonEntity
> instead which has Employable, Managerable and Traderable (bad words but hope
> you get the idea) as role interfaces. It is static that a Person *can* be
> any of these things, but the *actual* roles played by any particular
> instance at any particular time can change. The Employee/Manager/Trader
> roles can then either be values or entities, depending on what you want to
> accomplish.
>
> /Rickard
>
> 1. Does it mean there is no (much value in)  inheritance in COP?
2. Does it mean e.g properties one usually expect to find both in Manager
and Employee like name, department are modelled as separate roles e.g.
HasName, InDepartment (then the query findByName can be implemented for all
entities with HasName role)?
3. Is  there a mechanism to restrict/define what *actual* roles an entity
can play? Or is it the context responsibility to check if a Person can play
the Manger role and this info should be part of entity/role state?

Jacek
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to