Search code examples
classinheritanceinterfaceumlclass-diagram

Classes that inherit from interfaces but implement additional methods in UML diagram


I have to do an UML class diagram for a project in which I implement an interface with abstract methods for RL algorithms. I implement several algorithms that implement an interface but implement additional methods depending on the algorithm. How can I capture that in an UML diagram? I have thought in including a box with the generic name "Algorithm" and the attributes and methods "Algorithm specific attributes/methods", would that be correct in the UML framework?


Solution

  • A class should not inherit an interface but realize (aka implements) it. Graphically, you'll use the same notation than inheritance but with a dashed line:

    enter image description here

    Your case is a classic case of interface realization, as you'll find for example in a strategy pattern. The fact that you add other operations (aka methods) is completely normal and does not require anything special.

    If you're using abstract classes instead of interfaces, then you may use inheritance:

    enter image description here