diff --git a/Lectures/L28_ParnasTables/ParnasTables.pdf b/Lectures/L28_ParnasTables/ParnasTables.pdf index a5cd6f409ea9546fa171e3c809b202fd9d21cfb0..00c7dd4746a809e42bcd622ed7fa04eabb13a888 100644 Binary files a/Lectures/L28_ParnasTables/ParnasTables.pdf and b/Lectures/L28_ParnasTables/ParnasTables.pdf differ diff --git a/Lectures/L28_ParnasTables/ParnasTables.tex b/Lectures/L28_ParnasTables/ParnasTables.tex index cb9fffd6df21937ee67b9f83542b0d8cd7241095..fa605cdfc22b22184aeb029aeb27be0cf11831ad 100755 --- a/Lectures/L28_ParnasTables/ParnasTables.tex +++ b/Lectures/L28_ParnasTables/ParnasTables.tex @@ -29,7 +29,7 @@ \mode<presentation>{} \input{../def-beamer} -\Drafttrue +\Draftfalse \newcommand{\topicTitle}{28 Parnas Tables} \ifDraft @@ -54,7 +54,7 @@ \begin{itemize} \item Today's slide are partially based on slides by Dr.\ Wassyng \item Administrative details -\item Translating English to Math exercise +\item Design patterns \item Motivating example: midterm question \item History of tables \item Example tables @@ -78,16 +78,17 @@ TBD { \begin{itemize} -\item A3 deadlines +\item A3 \begin{itemize} -\item Part 2 - Code: due 11:59 pm Mar 20 -\item \structure{Part 1 spec available in repo} +\item Part 1 - Solution: Mar 18 +\item Part 2 - Code: due 11:59 pm Mar 26 \end{itemize} \item A4 \bi \item Your own design and specification -\item Due April 3 at 11:59 pm +\item Model module for game of Freecell +\item Due April 9 at 11:59 pm \ei \end{itemize} @@ -99,178 +100,75 @@ TBD %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} -\frametitle{Exercise} - -\bi -\item - \href{http://www.lonelyplanet.com/blog/2011/11/24/lost-in-translation-our-top-20-photos/}{For - SE Section} -\ei - -Consider an array $D$ with index values ranging from $1$ to $n$. The subject of this example is part of a specification -for a subprogram that will count how many times a particular given value occurs in the array $D$.\\ -~\newline - -The goal of this exercise is to write a postcondition for the subprogram, relating the various relevant variablesÕ -values when the search is complete. - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} -\frametitle{Exercise Continued} - -Understand the task in the original language - -\begin{itemize} - -\item Identify objects referred to (look for nouns in the original English text) -\item<2-> \structure<2>{Array $D$, index value, times (count), particular given value, relevant variables's value} -\item Identify missing information -\item<3-> \structure<3>{Names of variable for: index, times (count), particular given value} -\item<4-> \structure<4>{Are there any other relevant variables?} -\end{itemize} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} -\frametitle{Exercise} - -\begin{itemize} - -\item Identify missing information -\item Names of variable for -\begin{itemize} -\item Index: assume $i$ -\item Times (count): ask the author of the task, assume $\mathit{count}$ -\item Particular given value: Ask the author of the task, assume $\mathit{key}$ -\item Are there any other relevant variables? (no?) -\end{itemize} -\end{itemize} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} -\frametitle{Exercise Continued} - -\begin{itemize} -\item Close the gap between English text and mathematics -\begin{itemize} -\item Reword the English text to be closer to mathematics -\item Use the English verb $\mathit{count}$ -\end{itemize} - -\end{itemize} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} -\frametitle{Exercise Continued} +\frametitle{Command Processor Pattern} \begin{itemize} -\item The English verb $count$ means, in programming language and in terms closer to mathematics, $\mathit{add}$ $1$ -\item But this is a dynamic (action) concept -\item The corresponding static (state, relational) concept in mathematics is the function \textit{addition with 1}, -that is $+1$ +\item Context: User interfaces which must be flexible or provide functionality that goes beyond the direct handling of +user functions. Examples are undo facilities or logging functions +\item Problem: We want a well-structured solution for mapping an interface to the internal functionality of a system. +All `extras' which have to do with the way user commands are input, additional commands such as undo and redo, and any +non-application-specific processing of user commands, such as logging, should be kept separate from the interface to +the internal functionality. \end{itemize} \end{frame} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} -\frametitle{Exercise Continued} +\frametitle{Command Processor Pattern Continued} \begin{itemize} -\item The occurrence of the particular given value in an array element in $D$ -\item $D[i] = \mathit{key}$ -\item A condition for the addition with 1 -\item The repetition over a variable number of index values suggests quantification with the function addition and -with the argument $1$ -\item $+(i : ? | ... \wedge D[i] = \mathit{key} : 1)$ +\item Solution: A separate component, the \structure{command processor}, takes care of all commands. The command +processor component schedules the execution of commands, stores them for later undo, logs them for later analysis, and +so on. The actual execution of the command is delegated to a supplier component within the application. \end{itemize} \end{frame} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} -\frametitle{Exercise Continued} +\frametitle{Adapter Design Pattern} -Identify relationships between essential objects - -\begin{itemize} - -\item Array $D$, index value, particular given value: $D[i] = \mathit{key}$ -\item Combine the above with count ($+$ conditionally with $1$) -\item $\mathit{count} = +(i: \mathbb{N} | ... \leq i \leq ... \wedge D[i] = \mathit{key} : 1)$ -\item Range of $i$ missing -\item Refer to original English text: $1$ to $n$ -\item $\mathit{count} = +(i: \mathbb{N} | 1 \leq i \leq n \wedge D[i] = \mathit{key} : 1)$ -\end{itemize} +\structure{When have we used the adapter (or wrapper) design pattern?} \end{frame} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} -\frametitle{Exercise: New Glossary Entry} - -Now we have a new entry for our glossary +\frametitle{Adapter Design Pattern} -\begin{itemize} - -\item count: $ +(i: \mathbb{N} | ... \leq i \leq ... \wedge ... : 1)$, where the ... defines the range of the -quantified variable and the condition for counting - -\end{itemize} +\includegraphics[scale=0.7]{../Figures/500px-AdapterPatternForWiki.jpg} \end{frame} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} -\frametitle{Summary} - -\begin{itemize} +\frametitle{Factory Pattern} -\item Knowledge of English and Mathematics is necessary but not sufficient to translate into Mathematics -\item Knowledge of subject area also needed -\item Translating skills needed -\item The three are different +\includegraphics[scale=0.55]{../Figures/factory_pattern_uml_diagram.jpg} -\end{itemize} +\href{https://www.tutorialspoint.com/design_pattern/factory_pattern.htm}{Code} \end{frame} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} -\frametitle{Summary} +\frametitle{Singleton Pattern} -\begin{itemize} - -\item Compile your own glossary -\item Make intermediate steps and expressions conscious -\item Modularize -\item Organize systematically -\item KISSS -\end{itemize} +\includegraphics[scale=1.7]{../Figures/Singleton.jpg} \end{frame} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Tables Motivating Example: ptOn(c, s)}