开发者

Subclasses and abstract classes in DDD

开发者 https://www.devze.com 2022-12-19 07:46 出处:网络
I have an abstract ba开发者_开发技巧se class called Person with subclasses Employee and Customer.

I have an abstract ba开发者_开发技巧se class called Person with subclasses Employee and Customer.

How do you deal with the situation where Employee is also a Customer? How would this series of entities be created?

Cheers


If you want Employee to be a Customer, then Customer probably should not derive from person, but be it's own hierarchy of classes, which (typically) encapsulates a Person.

In many ways this makes more sense, since a Customer may also be a company or other form of entity, and not a Person.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号