Is it possible to have an empty class inheriting attributes/operations from another?

Viewed 195

I currently have 4 classes, User, Guest, Helper and Admin: The User class defines the main attributes and operations that each subclass will have/be able to do. Admin has the most operations (highest access level). Helper has the second-highest access level, and Guest has the lowest.

My current problem is that since the User class defines every operation and attribute for the Guest class, the Guest class inherits everything and therefore on the UML class diagram it will appear empty if that makes sense. The Helper and Admin classes will have operations but no attributes since they inherit all the same attributes from the User class.

Is it possible to have an empty class that inherits everything from another class, as well as classes that have operations but no attributes since they are inherited from another class?

Edit: is it also possible to have the same attribute/operation in multiple classes?

1 Answers

It is perfectly possible in UML to have an empty class: the UML syntax clarifies that a class may have 0..* properties and operations.

If a class inherits from another one, it would automatically gets its properties and operations. In this case, you should in principle not repeat the inherited members. If you nevertheless desire to visually remind them, you can precede them with a caret (^)

It is possible that the class inherits all its properties and operations and this appear as empty in the diagram

Related