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

Removing is_init from queueADT properties

parent 31c98fec
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -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}
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