summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlli Salli <olli.salli@collabora.co.uk>2012-05-21 19:00:22 (GMT)
committerOlli Salli <olli.salli@collabora.co.uk>2012-05-21 19:00:22 (GMT)
commit62bf3b640999afcd8ff1e94b990511a4631f4a8f (patch)
tree9cb47de5004cb6cd65f741fb4d85e573a8d8ed6d
parenta6a22518c991f645b9348d65c99982e7f8b02406 (diff)
downloaddbus-rad-62bf3b640999afcd8ff1e94b990511a4631f4a8f.tar.gz
dbus-rad-62bf3b640999afcd8ff1e94b990511a4631f4a8f.tar.xz
Clean up and illustrate Section 2.2 (OO inheritance)
-rw-r--r--Makefile2
-rw-r--r--coloredpoint.diabin0 -> 2091 bytes
-rw-r--r--gradu.tex28
-rw-r--r--miidag_dot.dot22
4 files changed, 45 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 070ebfc..55f0c75 100644
--- a/Makefile
+++ b/Makefile
@@ -27,6 +27,7 @@ FIGURES=abdeadlock_msc.pdf \
basicpubsub_dot.pdf \
cachingproxy_dia.pdf \
centralizedpubsub_dot.pdf \
+ coloredpoint_dia.pdf \
connlifecycle_msc.pdf \
contactmultiplexing_dia.pdf \
contactscheme_dot.pdf \
@@ -39,6 +40,7 @@ FIGURES=abdeadlock_msc.pdf \
kickreordering_msc.pdf \
localstatecopy_msc.pdf \
lostpackets_msc.pdf \
+ miidag_dot.pdf \
modularprivileges_twopi.pdf \
objectsclasses_dot.pdf \
pendingcomposite_dia.pdf \
diff --git a/coloredpoint.dia b/coloredpoint.dia
new file mode 100644
index 0000000..8752fd1
--- /dev/null
+++ b/coloredpoint.dia
Binary files differ
diff --git a/gradu.tex b/gradu.tex
index e42ebf9..29794a2 100644
--- a/gradu.tex
+++ b/gradu.tex
@@ -434,13 +434,20 @@ optimization in an inter-process context.
\label{sec:inheritance}
\mbox{SIMULA} classes could already be used as ``prefixes'' in each other, such
-that a class would \emph{inherit} all data and actions from its prefixes
-\cite{dahletal68}. A class inheriting members from a prefix class is called a \emph{subclass}. New
-members declared in the subclass make it a conceptual specialization of the prefix class (also
+that a class would \emph{inherit} all data and actions from the classes declared as its prefixes
+\cite{dahletal68}. A class that inherits members from a prefix class is called a \emph{subclass}.
+New members declared in the subclass make it a conceptual specialization of the prefix class (also
called \emph{superclass} or ``\emph{parent}'' class. For example, there could be a \verb|Point|
class which models a point in a two-dimensional plane. A \verb|ColoredPoint| class could use it as a
prefix, but add a color attribute. Thus, all \verb|ColoredPoint|s could be considered \verb|Point|s,
-but not the other way around.
+but not the other way around. This example is illustrated in
+Figure~\ref{fig:inheritance:coloredpoint}.
+
+\begin{figure}[ht!]
+\caption{Specializing classes through inheritance}
+\label{fig:inheritance:coloredpoint}
+\includegraphics[width=\textwidth]{coloredpoint_dia}
+\end{figure}
Class inheritance can be applied recursively. The ''grand\-parent'', ''grand-grand\-pa\-rent''
etc.~classes which result are collectively called the \emph{ancestors} of a class. Data and actions
@@ -461,9 +468,16 @@ operation should do, and the derived classes define how to do it.
A fairly natural extension to the concept of inheritance is being able to derive a subclass from
multiple superclasses simultaneously. This is called \emph{multiple inheritance}. In contrast with the
previously presented concept of single inheritance, the classes in multiple inheritance schemes
-form a directed acyclic graph topology. Multiple inheritance complicates subtype polymorphism
-somewhat: as it is possible for multiple classes at the same level of the inheritance hierarchy to
-define a common operation, there is ambiguity in which definition should be used \cite{snyder86}.
+form a directed acyclic graph topology, as shown in Figure~\ref{fig:inheritance:miidag}. Multiple
+inheritance complicates subtype polymorphism somewhat: as it is possible for multiple classes at the
+same level of the inheritance hierarchy to define a common operation, there is ambiguity in which
+definition should be used \cite{snyder86}.
+
+\begin{figure}[ht!]
+\caption{Example of multiple inheritance}
+\label{fig:inheritance:miidag}
+\includegraphics[width=\textwidth]{miidag_dot}
+\end{figure}
\subsection{Implications on typing}
diff --git a/miidag_dot.dot b/miidag_dot.dot
new file mode 100644
index 0000000..f7c51b6
--- /dev/null
+++ b/miidag_dot.dot
@@ -0,0 +1,22 @@
+digraph miidag {
+ graph [margin=0.10];
+ rankdir=BT;
+
+ node [shape=box];
+ edge [dir=back, arrowtail=odiamond];
+
+ car [label="Car"];
+
+ sedan [label="Sedan"];
+ suv [label="Sport utility vehicle"];
+ wagon [label="Station wagon"];
+
+ sedan -> car;
+ suv -> car;
+ wagon -> car;
+
+ crossover [label="Crossover"];
+
+ crossover -> suv;
+ crossover -> wagon;
+}