Is it ever valid to convert an object from a base class to a subclass

后端 未结 6 1782
无人共我
无人共我 2020-12-11 01:38

In my application at the moment I have (as in so many other applications) an entity called Contact, which represents any person. At its most basic level this is

6条回答
  •  孤城傲影
    2020-12-11 02:15

    Contact is an attribute of Employee. Worker (your Employee) is a role, Manager is a role. Worker and Manager are both still Employee, but have Roles. Role is an IS IN relationship, Employee is an AM A relationship, and Contact is a HAS A relationship. Employee HAS A Contact (1-1 relationship) One contact per employee (1-M if they have two phones etc but I digress) Employee IS IN Role (M-M relationship) Many employees many Roles Employee Is A (M-1 relatiohship) - Many employees, all of employee type.

    So you are changing roles.

提交回复
热议问题