diff --git a/Lectures/L26_SpecViaUML/SpecViaUML.pdf b/Lectures/L26_SpecViaUML/SpecViaUML.pdf index a9b894e7c503b98221c5eccff8208bcd26440054..db206962bd31c5b6f0df2769c9d8c95e46b70fa7 100644 Binary files a/Lectures/L26_SpecViaUML/SpecViaUML.pdf and b/Lectures/L26_SpecViaUML/SpecViaUML.pdf differ diff --git a/Lectures/L26_SpecViaUML/SpecViaUML.tex b/Lectures/L26_SpecViaUML/SpecViaUML.tex index ed9af30abc690638c8e624111f2a31ddc8e91461..81a0f3216407e53991c4858edf3849255d564060 100755 --- a/Lectures/L26_SpecViaUML/SpecViaUML.tex +++ b/Lectures/L26_SpecViaUML/SpecViaUML.tex @@ -23,9 +23,9 @@ \mode<presentation>{} \input{../def-beamer} -\Drafttrue +\Draftfalse -\newcommand{\topicTitle}{27 Specification Via UML (Ch.\ 5 and others)} +\newcommand{\topicTitle}{26 Specification Via UML (Ch.\ 5 and others)} \ifDraft \newcommand{\topic}{\topicTitle~DRAFT} \else @@ -47,11 +47,13 @@ \begin{itemize} \item Administrative details +\item Software tool of the day \item Best specification technique? +\item Designing spec of modules \item Interfaces in UML \bi \item Measurable interface -\item Measurer interface +\item Multiple inheritance example \ei \item Generic classes in UML \item Use cases with UML @@ -71,18 +73,17 @@ TBD { \begin{itemize} -\item \structure{Who has skimmed the homework problem?} -\item Some delay likely in grading A2 -\item A3 deadlines +\item A3 \begin{itemize} -\item Part 1 - Specification: due 11:59 pm \structure{Mar 11} -\item Part 2 - Code: due 11:59 pm Mar 20 +\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 \item Sources of slides @@ -100,22 +101,21 @@ TBD %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} -\frametitle{Best?} +\frametitle{Software Tool of the Day} -\bi -\item \structure{What is the best software development tool?} -\item \structure{What is the most important software design principle?} -\item \structure{What is the best specification technique?} -\ei +\href{https://www.draw.io/}{draw.io} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} -\frametitle{Best Continued} +\frametitle{Best?} \bi +\item \structure{What is the best software development tool?} +\item \structure{What is the most important software design principle?} +\item \structure{What is the best specification technique?} \item \structure{What is the best programming language?} \item \structure{What is the best engineering/scientific discipline?} \item \structure{What is the best movie? video game?} @@ -131,8 +131,9 @@ TBD \frametitle{Deciding the Best Strategy For a Given Problem} \bi +\item Many ways to accomplish the same goals, each with pros and cons \item What is the approach at your company? -\item Likely maintenance, so many decisions have likely been made. +\item Likely maintenance, so many decisions have likely been made \item What tools/techniques/programming language etc.\ do you know? \item What can you afford in terms of cost/time? \item What tool is appropriate for the task at hand? @@ -151,110 +152,105 @@ TBD %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} -\frametitle{UML Diagram of Measurable Interface} - -\includegraphics[scale=0.65]{../Figures/UMLDataSetMeasurableInterface.pdf} +\frametitle{Modelling Larger Components} \begin{itemize} -\item Realization arrow should have an outline triangle -\item UML diagram can also show interface method names -\item Realization arrow is like weak generalization (inheritance) + +\item From last day, Baber focuses on translating low level mathematical + expressions +\item In our specification, we will also need to organize the information +\item For larger problems, think about your types, Abstract Data Types and + Abstract objects +\item Interactively switch between types, ADTs, Abstract Objects and detailed + mathematical spec +\item Example +\bi +\item Modelling game state for + \href{https://www.freecell-solitaire-download.com/rules.html} {Freecell} +\item \structure{What are some potential types?} %suitT, rankT, cardT, deckT, + %stackT, gameBoard +\item \structure{What are some mathematical expressions you will need?} %is_validMove +\ei + \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\begin{frame}[allowframebreaks] -\frametitle{DataSet Without Interface} +\begin{frame} +\frametitle{Base For Examples: DataSet} -\lstset{language=java,breaklines=true,showspaces=false,showstringspaces=false,breakatwhitespace=true} -\noindent \lstinputlisting{./src/DataSet.java} +\href{https://gitlab.cas.mcmaster.ca/smiths/se2aa4_cs2me3/tree/master/Lectures/L26_SpecViaUML/DataSet} +{Data Set with Doubles} \end{frame} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame}[allowframebreaks] -\frametitle{PointT} -\lstset{language=java,breaklines=true,showspaces=false,showstringspaces=false,breakatwhitespace=true} -\noindent \lstinputlisting{./src/PointT.java} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\end{frame} +\begin{frame} +\frametitle{UML Diagram Datasets of PointT and BankAccount} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\medskip -\begin{frame}[allowframebreaks] -\frametitle{DataSet for Points} -\lstset{language=java,breaklines=true,showspaces=false,showstringspaces=false,breakatwhitespace=true} -\noindent \lstinputlisting{./src/DataSetPoint.java} +\includegraphics[scale=0.85]{DataSetsAggregation.pdf} \end{frame} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\begin{frame}[allowframebreaks] -\frametitle{Bank Account Class} -\lstset{language=java,breaklines=true,showspaces=false,showstringspaces=false,breakatwhitespace=true} -\noindent \lstinputlisting{./src/BankAccount.java} +\begin{frame} +\frametitle{Code for DataSetPointT and DataSetBankAccount} -\end{frame} +\href{https://gitlab.cas.mcmaster.ca/smiths/se2aa4_cs2me3/tree/master/Lectures/L26_SpecViaUML/DataSetPointT} +{Data Set with PointT}\\ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +~\newline -\begin{frame}[allowframebreaks] -\frametitle{DataSet for Bank Accounts} -\lstset{language=java,breaklines=true,showspaces=false,showstringspaces=false,breakatwhitespace=true} -\noindent \lstinputlisting{./src/DataSetBankAccount.java} +\href{https://gitlab.cas.mcmaster.ca/smiths/se2aa4_cs2me3/tree/master/Lectures/L26_SpecViaUML/DataSetBankAccount} +{Data Set with BankAccount} \end{frame} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\begin{frame}[allowframebreaks] -\frametitle{Measurable Interface} -\lstset{language=java,breaklines=true,showspaces=false,showstringspaces=false,breakatwhitespace=true} -\noindent \lstinputlisting{./src/Measurable.java} +\begin{frame} +\frametitle{Problems} +\bi +\item Inadequate reuse +\item Maintenance challenge +\item Examples only differ in the measure +\ei \end{frame} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\begin{frame}[allowframebreaks] -\frametitle{Data Set with Measurable Interface} -\lstset{language=java,breaklines=true,showspaces=false,showstringspaces=false,breakatwhitespace=true} -\noindent \lstinputlisting{./src/DataSetInterface.java} +\begin{frame} +\frametitle{UML Diagram of Measurable Interface} -\end{frame} +\medskip -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\includegraphics[scale=0.85]{MeasurableInterface.pdf} -\begin{frame}[allowframebreaks] -\frametitle{PointT with Measurable Interface} -\lstset{language=java,breaklines=true,showspaces=false,showstringspaces=false,breakatwhitespace=true} -\noindent \lstinputlisting{./src/PointTInterface.java} +\begin{itemize} +\item UML diagram can also show interface method names +\item Realization arrow is like weak generalization (inheritance) +\end{itemize} \end{frame} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame}[allowframebreaks] -\frametitle{Bank Account with Measurable Interface} -\lstset{language=java,breaklines=true,showspaces=false,showstringspaces=false,breakatwhitespace=true} -\noindent \lstinputlisting{./src/BankAccountInterface.java} - -\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame} +\frametitle{Code For DataSetInterface} -\begin{frame}[allowframebreaks] -\frametitle{Using DataSet} -\lstset{language=java,breaklines=true,showspaces=false,showstringspaces=false,breakatwhitespace=true} -\noindent \lstinputlisting{./src/DataSetTest.java} +\href{https://gitlab.cas.mcmaster.ca/smiths/se2aa4_cs2me3/tree/master/Lectures/L26_SpecViaUML/DataSetInterface} +{Data Set with Measurable Interface} \end{frame} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Interface Strategy} @@ -265,15 +261,22 @@ TBD \item You can measure an object in only one way \end{itemize} \item Move responsibility for measuring outside of objects themselves +\item Java +\bi \item Have another object carry out the comparison \item Introduce a Measurer interface +\ei +\item C++ +\bi +\item Multiple inheritance +\ei \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} -\frametitle{UML Diagram of Measurer Interface} +\frametitle{UML Diagram of Measurer Interface (Java)} \includegraphics[scale=0.55]{../Figures/UMLDataSetMeasurerInterface.pdf} @@ -286,109 +289,11 @@ TBD %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\begin{frame}[allowframebreaks] -\frametitle{Measurer Interface} - -\lstset{language=java,breaklines=true,showspaces=false,showstringspaces=false,breakatwhitespace=true} -\noindent \lstinputlisting{./src/Measurer.java} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame}[allowframebreaks] -\frametitle{Data Set with New Strategy} - -\lstset{language=java,breaklines=true,showspaces=false,showstringspaces=false,breakatwhitespace=true} - -\noindent \lstinputlisting{./src/DataSetStrategy.java} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame}[allowframebreaks] -\frametitle{Rectangle Measurer} - -\lstset{language=java,breaklines=true,showspaces=false,showstringspaces=false,breakatwhitespace=true} - -\noindent \lstinputlisting{./src/RectangleMeasurer.java} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame}[allowframebreaks] -\frametitle{Using Rectangle Measurer} - -\lstset{language=java,breaklines=true,showspaces=false,showstringspaces=false,breakatwhitespace=true} - -\noindent \lstinputlisting{./src/DataSetStrategyTest.java} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame}[fragile] -\frametitle{ {\tt Comparable} Versus {\tt Comparator}} - -\begin{itemize} -\item Comparable similar UML diagram to Measurable -\item Comparator similar UML diagram to Measurer -\end{itemize} - -\begin{lstlisting} -public interface Comparable<T> -{ - int compareTo(T obj); -} -\end{lstlisting} - -\begin{lstlisting} -public interface Comparator<T> -{ - public int compare(T obj1, T obj2); -} -\end{lstlisting} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - \begin{frame} -\frametitle{Interface Versus Abstract} -\begin{itemize} -\item \structure{What is the difference between an interface and an abstract class?} -\end{itemize} -\end{frame} +\frametitle{UML Diagram of Multiple Inheritance} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\includegraphics[scale=0.75]{MeasurableInterfaceInheritance.pdf} -\begin{frame} -%\frametitle{Differences Between Interface and Abstract} -\begin{itemize} -\item Interface -\bi -\item Methods are implicitly abstract and public -\item Methods can have default implementation ( JDK 8) -\item Cannot have constructors -\item Variables are final -\item Can only extend interfaces -\item Classes can extend multiple instances -\item Appropriate for unrelated classes -\ei -\item Abstract class -\bi -\item At least one method is declared as abstract -\item Some methods can implement a default behaviour -\item Cannot instantiate them, but can have constructors -\item Variables are not necessarily final -\item Can extend other class -\item Can implement multiple interfaces -\item Classes can extend only one abstract class -\item Sharing code between closely related classes -\ei -\end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%