UML Abstract Class vs Interface

What is the difference between an abstract class and an interface? This tutorial shows you similarities and differences between these two object-oriented programming concepts.

UML Abstract Class

An abstract class can contain abstract attributes and operations. The abstract members do not contain implementation. Unlike an interface, an abstract class can also include non-abstract members with implementation. An abstract class cannot be instantiated.

There is also another difference between the UML interface and UML abstract class. When a UML abstract class represents a class in single-inheritance object-oriented languages (as C# or Java) - a class can be inherited only from one abstract class, but it can implement multiple interfaces.

UML Abstract Class
UML Abstract Class

UML Interface

An interface is a classifier that contains attributes and operations without any implementation details. An interface cannot be instantiated. UML interface can be depicted in the same way as the UML class or using "lollipop" notation.

UML Interface
UML Interface

Comments

Vladimir Sekerka 7 January 2022 8:37:34

Suggestion for improvement

Hello.

There is no clear difference from this description. At least not me (I'm new to UML). An abstract class works on top of other classes without knowing the details of the implementation (eg a class that can sort any field if the operator <is defined) - i. an abstract class can contain an abstract code. (?)

There is only a definition of an interface that some interfaces exist (i.e. a class implementing these functions can use these functions in its calculation) but there must be another class that implements the given functions. E.g. object for archiving other objects.

What are the typical examples of using an abstract class and interface?

It is not yet clear from the figure when the interface with the ball is used in the interface and when with "C". and how to draw some interfaces in the example (the picture only shows the elements that will be used.

(The text has been machine-translated.)

Dusan Rodina - softwareideas.net 10 January 2022 10:14:43

RE: Namet na zlepsenie

Hello,

thank you for your suggestions. The article will be furt Additional details will be added to the article.

New Comment

Comment