Skip to content
Snippets Groups Projects
Commit 03ebddd8 authored by W. Spencer Smith's avatar W. Spencer Smith
Browse files

Updates to L12 on Object Oriented Design - more questions

parent ad881481
No related branches found
No related tags found
No related merge requests found
No preview for this file type
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
unicode=false} unicode=false}
\urlstyle{same} \urlstyle{same}
\usepackage{listings}
\usepackage{booktabs} \usepackage{booktabs}
\useoutertheme{split} %so the footline can be seen, without needing pgfpages \useoutertheme{split} %so the footline can be seen, without needing pgfpages
...@@ -21,7 +23,7 @@ ...@@ -21,7 +23,7 @@
\mode<presentation>{} \mode<presentation>{}
\input{../def-beamer} \input{../def-beamer}
\Drafttrue \Draftfalse
\newcommand{\topicTitle}{12 Object Oriented Design (Ghezzi Ch.\ 4)} \newcommand{\topicTitle}{12 Object Oriented Design (Ghezzi Ch.\ 4)}
\ifDraft \ifDraft
...@@ -36,6 +38,9 @@ ...@@ -36,6 +38,9 @@
\input{../footline} \input{../footline}
\lstset{language=python, breaklines=true, showspaces=false,
showstringspaces=false, breakatwhitespace=true, texcl=true, escapeinside={\%*}{*)}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame} \begin{frame}
...@@ -61,21 +66,11 @@ TBD ...@@ -61,21 +66,11 @@ TBD
\else \else
{ {
\begin{itemize} \begin{itemize}
\item NSERC Undergraduate Student Research Award
\item Assignment 1 \item Assignment 1
\begin{itemize} \begin{itemize}
\item E-mail your partner if you haven't already done so \item Part 2: January 31, 2018
\item E-mail the instructor if you haven't received your partner's code
\item Lab report due by 11:59 pm February 2
\end{itemize}
\item Assignment 2
\begin{itemize}
\item Files due by 11:59 pm Feb 15
\item E-mail partner files by 11:59 pm Feb 16
\item Lab report due by 11:59 pm Feb 27
\end{itemize} \end{itemize}
\item Questions?
\end{itemize} \end{itemize}
} }
\fi \fi
...@@ -94,13 +89,119 @@ TBD ...@@ -94,13 +89,119 @@ TBD
to review changes between commits to review changes between commits
\item Review before committing: \texttt{git difftool} \item Review before committing: \texttt{git difftool}
\item To better deal with changes, use a ``hard wrap'' at an 80 column width, \item To better deal with changes, use a ``hard wrap'' at an 80 column width,
even for LaTeX documents even for LaTeX documents (\structure{why?})
\end{itemize} \end{itemize}
\end{frame} \end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\frametitle{Set Idiom (H\&S)}
\begin{tabular}{| l | l | l | l |}
\hline
\textbf{Routine name} & \textbf{In} & \textbf{Out} & \textbf{Exceptions}\\
\hline
set\_add & T & ~ & Member, Full\\
\hline
set\_del & T & ~ & NotMember\\
\hline
set\_member & T & boolean & ~\\
\hline
set\_size & ~ & integer & ~\\
\hline
\end{tabular}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\frametitle{Sequence Idiom (H\&S)}
\begin{tabular}{| l | l | l | l |}
\hline
\textbf{Routine name} & \textbf{In} & \textbf{Out} & \textbf{Exceptions}\\
\hline
seq\_init & ~ & ~ & ~\\
\hline
seq\_add & integer, T & ~ & PosOutOfRange, Full\\
\hline
seq\_del & integer & ~ & PosOutOfRange\\
\hline
seq\_setval & integer, T & ~ & PosOutOfRange\\
\hline
seq\_getval & integer & T & PosOutOfRange\\
\hline
seq\_size & ~ & integer & ~\\
\hline
seq\_start & ~ & ~ & ~\\
\hline
seq\_next & ~ & T & AtEnd\\
\hline
seq\_end & ~ & boolean & ~\\
\hline
seq\_append & T & ~ & Full\\
\hline
\end{tabular}\\
~\\
\structure<1>{When would you use seq\_next in the interface, and exclude
seq\_getval?}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\frametitle{Tuple Idiom Version 1 (H\&S)}
\begin{tabular}{| l | l | l | l |}
\hline
\textbf{Routine name} & \textbf{In} & \textbf{Out} & \textbf{Exceptions}\\
\hline
tp\_init & ~ & ~ & ~\\
\hline
tp\_set\_f$_1$ & T$_1$ & ~ & ~\\
\hline
tp\_get\_f$_1$ & ~ & T$_1$ & ~\\
\hline
... & ... & ... & ...\\
\hline
tp\_set\_f$_N$ & T$_N$ & ~ & ~\\
\hline
tp\_get\_f$_N$ & ~ & T$_N$ & ~\\
\hline
\end{tabular}\\
~\\
\structure{What is a potential problem with this idiom, especially if there are
many fields to the tuple?}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\frametitle{Tuple Idiom Version 2 (H\&S)}
\begin{tabular}{| l | l | l | l |}
\hline
\textbf{Routine name} & \textbf{In} & \textbf{Out} & \textbf{Exceptions}\\
\hline
tp\_init & ~ & ~ & ~\\
\hline
tp\_set & T$_1$, T$_2$, ..., T$_N$ & ~ & ~\\
\hline
tp\_get & ~ & T & ~\\
\hline
\end{tabular}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame} \begin{frame}
\frametitle{Object Oriented Design} \frametitle{Object Oriented Design}
\begin{itemize} \begin{itemize}
...@@ -126,6 +227,13 @@ TBD ...@@ -126,6 +227,13 @@ TBD
\item A is a superclass of B \item A is a superclass of B
\item B is a subclass of A \item B is a subclass of A
\end{itemize} \end{itemize}
~\\
\structure<1>{In Python, what class do all classes inherit?}\\ %object
~\\
\structure<2>{What method inherited from object did we recently override?}\\
% __eq__
~\\
\end{frame} \end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
...@@ -196,14 +304,18 @@ def\_skill & skillT & ~ & ~\\ ...@@ -196,14 +304,18 @@ def\_skill & skillT & ~ & ~\\
\begin{itemize} \begin{itemize}
\item A way of building software incrementally \item A way of building software incrementally
\item Useful for long lived applications because new features can be added without breaking the old applications \item Useful for long lived applications because new features can be added
without breaking the old applications
\item A subclass defines a subtype \item A subclass defines a subtype
\item A subtype is substitutable for the parent type \item A subtype is substitutable for the parent type
\item Polymorphism - a variable referring to type A can refer to an object of type B if B is a subclass of A \item Polymorphism - a variable referring to type A can refer to an object of
\item Dynamic binding - the method invoked through a reference depends on the type of the object associated with the type B if B is a subclass of A
reference at runtime \item Dynamic binding - the method invoked through a reference depends on the
\item All instances of the sub-class are instances of the super-class, so the type of the sub-class is a subtype type of the object associated with the reference at runtime
\item All instances of Administrative\_Staff and Technical\_Staff are instances of Employee \item All instances of the sub-class are instances of the super-class, so the
type of the sub-class is a subtype
\item All instances of Administrative\_Staff and Technical\_Staff are instances
of Employee
\end{itemize} \end{itemize}
\end{frame} \end{frame}
...@@ -214,7 +326,10 @@ reference at runtime ...@@ -214,7 +326,10 @@ reference at runtime
emp1, emp2: Employee\\ emp1, emp2: Employee\\
emp3: Technical\_Staff\\ emp3: Technical\_Staff\\
~\\
\structure<1>{What assignments are allowed? That is, where would polymorphism
allow us to switch references to the RHS with what appears on the LHS?}\\
~\\
emp1 = Administrative\_Staff() \uncover<2->{\structure{$\surd$}}\\ emp1 = Administrative\_Staff() \uncover<2->{\structure{$\surd$}}\\
emp2 = Technical\_Staff() \uncover<3->{\structure{$\surd$}}\\ emp2 = Technical\_Staff() \uncover<3->{\structure{$\surd$}}\\
emp3 = emp1 \uncover<4->{\structure{$\times$}}\\ emp3 = emp1 \uncover<4->{\structure{$\times$}}\\
...@@ -249,8 +364,10 @@ emp3 = (Technical\_Staff) emp1 \uncover<5->{\structure{$\surd$}}\\ ...@@ -249,8 +364,10 @@ emp3 = (Technical\_Staff) emp1 \uncover<5->{\structure{$\surd$}}\\
\item UML (Unified Modelling Language) is a widely adopted standard notation for representing OO designs \item UML (Unified Modelling Language) is a widely adopted standard notation for representing OO designs
\item We introduce the UML class diagram \item We introduce the UML class diagram
\item Classes are described by boxes \item Classes are described by boxes
\end{itemize} \end{itemize}
\structure{Any guesses on what Parnas said UML stood for?} %Undefined Modelling Language
\end{frame} \end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
...@@ -275,6 +392,20 @@ emp3 = (Technical\_Staff) emp1 \uncover<5->{\structure{$\surd$}}\\ ...@@ -275,6 +392,20 @@ emp3 = (Technical\_Staff) emp1 \uncover<5->{\structure{$\surd$}}\\
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\frametitle{Class Diagram Versus MIS}
\begin{itemize}
\item \structure<1>{What information do the MIS and Class Diagram have in common?}
\item \structure<2>{What information does the MIS add?} %semantics
\item \structure<3>{What information does the Class Diagram add?} %richer set of
%uses relations
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame} \begin{frame}
\frametitle{UML Associations} \frametitle{UML Associations}
...@@ -409,7 +540,7 @@ PointMassT = ?\\ ...@@ -409,7 +540,7 @@ PointMassT = ?\\
\hline \hline
\textbf{Routine name} & \textbf{In} & \textbf{Out} & \textbf{Exceptions}\\ \textbf{Routine name} & \textbf{In} & \textbf{Out} & \textbf{Exceptions}\\
\hline \hline
new PointMassT & real, real, real & PointMassT & NegMassException\\ new PointMassT & real, real, real & PointMassT & NegMassExcept\\
\hline \hline
mval & ~ & real & ~\\ mval & ~ & real & ~\\
\hline \hline
...@@ -437,7 +568,7 @@ $ms$: real ...@@ -437,7 +568,7 @@ $ms$: real
\begin{itemize} \begin{itemize}
\item transition: $xc, yc, ms := x, y, m$ \item transition: $xc, yc, ms := x, y, m$
\item output: $out := \mathit{self}$ \item output: $out := \mathit{self}$
\item exception: $exc := (m < 0 \Rightarrow \mbox{NegativeMassException})$ \item exception: $exc := (m < 0 \Rightarrow \mbox{NegMassExcept})$
\end{itemize} \end{itemize}
~\newline ~\newline
\noindent force($p$): \noindent force($p$):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment