Skip to content
Snippets Groups Projects
Commit d5df4add authored by Sepehr Bayat's avatar Sepehr Bayat
Browse files

Delete T4.tex

parent 51345a84
No related branches found
No related tags found
No related merge requests found
% Define Document Class
% Class Options Include:
% notes, notesonly, handout, trans,
% hidesubsections, shadesubsections,
% inrow, blue, red, grey, brown
%--------------------------------------------------------------------------
\documentclass[xcolor=dvipsnames, shownotes, colorlinks]{beamer}
%--------------------------------------------------------------------------
% Define Package Theme
%--------------------------------------------------------------------------
\usepackage{color}
\usepackage[T1]{fontenc}
%% \usepackage{fix-cm}
\usepackage{hyperref}
\hypersetup{
urlcolor=cyan,
linkcolor=white
}
\usepackage{subfigure}
%% \usepackage{xspace}
\usepackage{}
\usepackage{enumerate}
\usetheme{Antibes}
\setbeamertemplate{sidebar}[right]
\usepackage{listings} % Code formatting
%% \usepackage{framed}
%% \usepackage{booktabs}
\usepackage{tabularx}
\usepackage{marvosym}
\usepackage{tikz}
\usetikzlibrary{shapes}
\usetikzlibrary{arrows}
\usetikzlibrary{calc,positioning}
\lstset{
language=Python,
basicstyle=\ttfamily\scriptsize,
tabsize=2,
breaklines=true,
prebreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}},
frame=single,
showstringspaces=true,
showspaces=false,
keywordstyle=\color{blue},
stringstyle=\color{magenta},
commentstyle=\color{ForestGreen},
literate={\#}{{\textcolor{ForestGreen}{\#}}}1 {@}{{\textcolor{blue}{\MVAt}}}1 {\$}{\vdots}1
}
%--------------------------------------------------------------------------
% Commands
%------------------------------------------------------------------------------
\newcommand*\oldmacro{}%
\let\oldmacro\insertshorttitle%
\renewcommand*\insertshorttitle{%
\oldmacro\hfill%
\insertframenumber\,/\,\inserttotalframenumber}
% Figure Source
\usepackage[absolute,overlay]{textpos}
\setbeamercolor{framesource}{fg=gray}
\setbeamerfont{framesource}{size=\tiny}
\newcommand{\source}[1]{\begin{textblock*}{\paperwidth}(-5pt,\textheight)
\begin{beamercolorbox}[ht=0.5cm,right]{framesource}
\usebeamerfont{framesource}\usebeamercolor[fg]{framesource} Source: {#1}
\end{beamercolorbox}
\end{textblock*}}
%------------------------------------------------------------------------------
% Presentation Title Slide
%--------------------------------------------------------------------------
\title{MIS Example}
\subtitle{CS 2ME3/SE 2AA4}
\author{Gurankash Singh}
\institute{Department of Computing and Software\\
McMaster University\\ }
\date{January 30 - Feburary 3}
%--------------------------------------------------------------------------
% Document
% To add notes to the slides use: \note{}
% Add \section{} or \subsection{} for use in table of contents
%--------------------------------------------------------------------------
\begin{document}
% Create Title Slide
\begin{frame}
\maketitle
\end{frame}
\section[Outline]{}
% Create Table of Contents Slide - Outline
\begin{frame}
\frametitle{Outline}
{\hypersetup{linkcolor=black}
\tableofcontents
}
\end{frame}
\section{What is a module?}
\begin{frame}
\frametitle{What is a module?}
\begin{itemize} \item A file with encapsulated code to implement a specific functionality
\item Ex: For designing a website with a login system, we may have a module that deals with logging out
\item A module comes with an "interface"
\item An interface includes things like functions and arguments of the function
\end{itemize}
\end{frame}
% --------------------------------------------------
% --------------------------------------------------
\begin{frame}
\frametitle{What is a MIS?}
\begin{itemize} \item Module Interface Specification
\item Specifices externally observable behaviour of a module
\item Not in language of implementation, but uses mathematical and application language
\item Internal implementations are not included in a MIS
\end{itemize}
\end{frame}
% --------------------------------------------------
% --------------------------------------------------
\section{MIS Template}
\begin{frame}
\frametitle{MIS Template Structure}
\begin{itemize}
\item Uses
\begin{itemize}
\item Imported constants, data types and access programs
\end{itemize}
\item Syntax
\begin{itemize}
\item Exported constants and types
\item Exported functions (access routine interface syntax)
\end{itemize}
\item Semantics
\begin{itemize}
\item State variables
\item State invariants
\item Assumptions
\item Access routine semantics
\item Local functions
\item Local types
\item Local constants
\item Considerations
\end{itemize}
\end{itemize}
\end{frame}
% --------------------------------------------------
% --------------------------------------------------
\section{Example}
\begin{frame}
\frametitle{Example }
Consider implementation of point masses on two dimensional plane
\begin{itemize}
\item Position P is represented by pair of real numbers (x,y)
\item Mass m is represented by a real number
\item Considering two point masses that have the corresponding positions and masses of $P_1$ and
$P_2$ and $m_1$ and $m_2$, respectively, the force $F$ exerted by one mass on the other is given by Newton's law of
universal gravitation:
$$F = G \frac{m_1 m_2}{r^2}$$
\noindent where $r$ is the distance between positions $P_1$ and $P_2$ and $G = 6.672 \times 10^{-11} \mbox{ N} \cdot
\mbox{m}^2/\mbox{kg}^2$.
\end{itemize}
\end{frame}
% --------------------------------------------------
% --------------------------------------------------
\subsection{Point ADT Module}
\begin{frame}
\frametitle{Point ADT Module }
\textbf{Template Module}\\
pointADT
\newline
\textbf{Uses}\\
N/A
\newline
\textbf{Syntax}\\
Exported Types:
\newline
pointT = ?
\end{frame}
% --------------------------------------------------
\begin{frame}
\textbf{Exported Access Programs}\\
~\newline
\begin{tabular}{| l | l | l | l |}
\hline
\textbf{Routine name} & \textbf{In} & \textbf{Out} & \textbf{Exceptions}\\
\hline
init & real, real & pointT & ~\\
\hline
xcoord & ~ & real & ~\\
\hline
ycoord & ~ & real & ~\\
\hline
dist & pointT & real & ~\\
\hline
\end{tabular}
\end{frame}
% --------------------------------------------------
\begin{frame}
\textbf{Semantics}
State Variables:
$xc$: real\\
$yc$: real
~\newline
\textbf{State Invariant}
None
~\newline
\textbf{Assumptions}
init() is called for each abstract object before any other access routine is called for that object
\end{frame}
% --------------------------------------------------
\begin{frame}
\frametitle{Point ADT Module}
\textbf{Access Routine Semantics}\\
init($x, y$):
\begin{itemize}
\item transition: $xc, yc := x, y$
\item output: $out := \mathit{self}$
\item exception: none
\end{itemize}
\noindent xcoord():
\begin{itemize}
\item output: $out := xc$
\item exception: none
\end{itemize}
\noindent ycoord():
\begin{itemize}
\item output: $out := yc$
\item exception: none
\end{itemize}
\noindent dist($p$):
\begin{itemize}
\item output: $out := \sqrt{(\mathit{self}.xc - p.\mbox{xcoord()})^2 + (\mathit{self}.yc - p.\mbox{ycoord()})^2}$
\item exception: none
\end{itemize}
\end{frame}
% --------------------------------------------------
\begin{frame}[fragile]
\frametitle{MIS Interface}
From the MIS we can deduce the interface of the code will look like:
\begin{lstlisting}
# Interface
class pointT:
# Constructor
def __init__(self, x, y):
# Selectors
def xcoord(self):
def ycoord(self):
def dist(self, p):
\end{lstlisting}
\end{frame}
% --------------------------------------------------
\begin{frame}
\frametitle{MIS Implementation}
\begin{center}
\textbf{See PointADT.py for implementation.}\\
\end{center}
\end{frame}
% --------------------------------------------------
%
%
%
%
%
%
% --------------------------------------------------
\subsection{Point Mass Module }
\begin{frame}
\frametitle{Point Mass Module }
\textbf{Template Module}\\
pointMassADT
\newline
\textbf{Uses}\\
PointADT
\newline
\textbf{Syntax}\\
Exported Types:
\newline
pointMassT = ?
\end{frame}
% --------------------------------------------------
\begin{frame}
\textbf{Exported Access Programs}\\
~\newline
\begin{tabular}{| l | l | l | l |}
\hline
\textbf{Routine name} & \textbf{In} & \textbf{Out} & \textbf{Exceptions}\\
\hline
init & pointT, real & pointMassT & ~\\
\hline
point & ~ & pointT & ~\\
\hline
mval & ~ & real & ~\\
\hline
force & pointMassT & real & ~\\
\hline
Fx & pointMassT & real & ~\\
\hline
\end{tabular}
\end{frame}
% --------------------------------------------------
\begin{frame}
\textbf{Semantics}
State Variables:
$pt$: pointT\\
$ms$: real
~\newline
\textbf{State Invariant}
None
~\newline
\textbf{Assumptions}
init() is called for each abstract object before any other access routine is called for that object
\end{frame}
% --------------------------------------------------
\begin{frame}
\textbf{Access Routine Semantics}\\
init($p, m$):
\begin{itemize}
\item transition: $pt, ms := p, m$
\item output: $out := \mathit{self}$
\item exception: none
\end{itemize}
\noindent point():
\begin{itemize}
\item output: $out := pt$
\item exception: none
\end{itemize}
\noindent mval():
\begin{itemize}
\item output: $out := ms$
\item exception: none
\end{itemize}
\end{frame}
% --------------------------------------------------
\begin{frame}
\noindent force($p$):
\begin{itemize}
\item output: $$out := \mathrm{UNIVERAL\_G} \frac{\mathit{self}.ms \times p.\mathrm{mval}()}
{\mathit{self}.pt.\mathrm{dist}(p.\mathrm{point()})^2}$$
\item exception: none
\end{itemize}
\noindent Fx($p$):
\begin{itemize}
\item output: $$out := \mathit{self}.\mathrm{force}(p) \frac{p.\mathrm{point()}.\mathrm{xcoord}() -
\mathit{self}.pt.\mathrm{xcoord}()}
{\mathit{self}.pt.\mathrm{dist}(p.\mathrm{point()})}$$
\item exception: none
\end{itemize}
\textbf{Local Constants}\\
UNIVERAL\_G $= 6.672 \times 10^{-11}$
\end{frame}
% --------------------------------------------------
\begin{frame}[fragile]
\frametitle{MIS Interface}
From the MIS we can deduce the interface of the code will look like:
\begin{lstlisting}
# Interface
class pointMassT:
#Constructor
def __init__(self, p, m):
#Selectors
def point(self):
def mval(self):
def force(self, p):
def Fx(self, p):
\end{lstlisting}
\end{frame}
% --------------------------------------------------
\begin{frame}
\frametitle{MIS Implementation}
\begin{center}
\textbf{See PointMassADT.py for implementation.}\\
\end{center}
\end{frame}
% --------------------------------------------------
% -----------------------------------------------------
\begin{frame}
\frametitle{Implementation files}
\begin{itemize}
\item Implementation files PointADT.py and PointMassADT.py can be found in the repo under Tutorial/T4/src
\end{itemize}
\end{frame}
\end{document}
\ No newline at end of file
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