diff --git a/Lectures/L11_Generic_MIS/Generic_MIS.pdf b/Lectures/L11_Generic_MIS/Generic_MIS.pdf index 55d2e248ee03371bbf2eddd841f877873d041ecd..2e346a617876d9cb0ca87f3b43b482d8fffedd77 100644 Binary files a/Lectures/L11_Generic_MIS/Generic_MIS.pdf and b/Lectures/L11_Generic_MIS/Generic_MIS.pdf differ diff --git a/Lectures/L11_Generic_MIS/Generic_MIS.tex b/Lectures/L11_Generic_MIS/Generic_MIS.tex index 9ee5fc22cd8abca434a452740448d520f7c52b55..860854207f3df6a1e15ed2669cc67b41c7a9c654 100755 --- a/Lectures/L11_Generic_MIS/Generic_MIS.tex +++ b/Lectures/L11_Generic_MIS/Generic_MIS.tex @@ -80,7 +80,6 @@ TBD \else { \begin{itemize} - \item Assignment 1 \begin{itemize} \item Partner files now in your repo @@ -589,7 +588,7 @@ $\{ \mathit{true} \}$ ~~~~~q\_init() -$\{ | s' | = 0 \wedge \mathit{is\_init}\}$ +$\{ | s' | = 0}$ ~\newline $\{ | s | < \mbox{MAX\_SIZE} \}$ @@ -602,196 +601,4 @@ $\{ | s' | = | s | + 1 \wedge s'[0] = x \wedge s'[1..|s'| - 1] = s[0..|s|-1]\}$ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\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} - -\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} - -\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}[fragile] -\frametitle{Example Subclass Exception in Python} -\ttfamily -\begin{lstlisting} -class Full(Exception): - def __init__(self, value): - self.value = value - def __str__(self): - return str(self.value) -\end{lstlisting} -\sffamily - -Example of raising the exception - -\ttfamily -\begin{lstlisting} - if size == Seq.MAX_SIZE: - raise Full("Maximum size exceeded") -\end{lstlisting} -\sffamily - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} - -\frametitle{Exception Signaling} - -\begin{itemize} -\item Useful to think about exceptions in the design process -\item Will need to decide how exception signalling will be done -\begin{itemize} -\item A special return value, a special status parameter, a global variable -\item Invoking an exception procedure -\item Using built-in language constructs -\end{itemize} -\item Caused by errors made by programmers, not by users -\item Write code so that it avoid exceptions -\item Exceptions will be particularly useful during testing -\end{itemize} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} - -\frametitle{Assumptions versus Exceptions} - -\begin{itemize} -\item The assumptions section lists assumptions the module developer is - permitted to make about the programmer's behaviour -\item Assumptions are expressed in prose -\item Use assumptions to simplify the MIS and to reduce the complexity of the - final implementation -\item Interface design should provide the programmer with a means to check so - that they can avoid exceptions -\item When an exceptions occurs no state transitions should take place, any - output is {\it don't care} -\end{itemize} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} - -\frametitle{Quality Criteria} - -\begin{itemize} -\item Consistent -\begin{itemize} -\item Name conventions -\item Ordering of parameters in argument lists -\item Exception handling, etc. -\end{itemize} -\item Essential - omit unnecessary features -\item General - cannot always predict how the module will be used -\item As implementation independent as possible -\item Minimal - avoid access routines with two potentially independent services -\item High cohesion - components are closely related -\item Low coupling - not strongly dependent on other modules -\item Opaque - information hiding -\end{itemize} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - \end{document}