Abstract Class
- Tags
- modelling
Is a class so [see page 3, general] that you would never create any direct instances of it, generally such classes contain abstract operations which can be named but not described algorithmically.
Abstract classes are modelled the same as regular classes except with the class name being italic and any abstract methods also being italic.
Interface
Is an extension of abstract classes where every method is abstract.
Interfaces can be drawn as classes with the <<interface>>
tag or as just a plain
circle with the interface name (this is known as the overview style).
\begin{figure}
\centering
\begin{tikzpicture}
\umlclass[type=interface]{Shape}{}{area(): Real}
\umlclass[y=-3, x=2]{Rectangle}{length: Real \\ width: Real}{area(): Real}
\umlclass[y=-3, x=-2]{Circle}{radius: Real}{area(): Real}
\umlVHreal{Rectangle}{Shape}
\umlVHreal{Circle}{Shape}
\umlsimpleinterface[y=-6, title=Shape2]{Shape}
\umlVHreal{Rectangle}{Shape}
\umlVHreal{Circle}{Shape}
\end{tikzpicture}
\caption{\label{fig:interface} Example of an interface with two concrete sub-classes.}
\end{figure}
An open circle and an encompassing half-circle can be used to plug interfaces
together. In fig:interface-plug Rectangle
is declared to satisfy the
implementation of Shape whereas ShapeList
requires an object satisfying that
interface.
The two can be drawn separately, however putting them together simplifies the
declaration.
\begin{figure}
\centering
\begin{tikzpicture}
\umlsimpleclass{Rectangle}
\umlsimpleclass[x=6]{ShapeList}
\umlassemblyconnector[interface=Shape, width=2em]{Rectangle}{ShapeList}
\umlprovidedinterface[interface=Moveable, width=2em]{Rectangle}
\end{tikzpicture}
\caption{\label{fig:interface-plug} Example of pluggable interface styles.}
\end{figure}