我的程序有一些抽象的“模块”。假设它是一个 GUI 模块。它只包含模块的接口及其类型——为了与其他模块兼容(在另一个模块中,我可以使用 GUI 模块及其类型,而不用担心它的实现)。
所以我有这样的东西:
GUI::Component //represent the abstract component (button, label etc.)
//so it's only the base class for components
GUI::Clickable //if any component is clickable, it must inherit from it
GUI::Button : public Component, public Clickable
GUI::Label : public Component
但即使 a LabelorButton只有虚拟方法(我猜它们是模块的接口)。GUI 模块实现的例如SomeGUIImp必须声明SomeButton : public GUI::Button和SomeLabel : public GUI::Label(由于对象工厂,它们对用户是透明的)。
我不想更改代码中的任何内容,我只想为它制作一个适当的 UML 图。
所有这些元素 ( Component, Clickable, Button) 都是接口吗?还是抽象类?
我想以某种方式表明LabelandButton比Component.
此外,最好展示Clickable(它的功能)和Component(它是所有组件的抽象基础)之间的区别。
当前解决方案(不确定)
我不能说 100% 为什么,但在我看来,也许Clickable是一个接口,Component是一个抽象类,Button只是普通类。
但这显示了模块内部的关系,忽略了Button(只有纯虚拟方法)也只是某些模块实现的声明?