Generalization and Specialization - What is the differences

坚强是说给别人听的谎言 提交于 2020-05-15 05:18:22

问题


I am having a hard time actually finding the difference between a Generalization and a Specialization, and when to use either one.

Can anyone enlighten me?

Eventually also an illustration using UML


回答1:


Animal is a generalization , Dog is specialization. Your superclass is a generalized class , but your subclass will be a specialized inheritor of your superclass. It becomes more specialized and less generalized as you move down the inheritance hierarchy .

Generalization

Generalization is the process of extracting shared characteristics from two or more classes, and combining them into a generalized superclass. Shared characteristics can be attributes, associations, or methods.

Specialization

If some new subclasses are created from an existing superclass to do specific job of the superclass, then it is known as specialization.

You can get more clear tutorial with UML diagrams here.



来源:https://stackoverflow.com/questions/17084034/generalization-and-specialization-what-is-the-differences

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!