

% add the PATH to retrieve cls and sty beamer styles files
\makeatletter
\providecommand*{\input@path}{}
\edef\input@path{{../../support/beamer/}\input@path}% prepend
\makeatother

% \documentclass{pharoslides}
% \documentclass[aspectratio=169]{pharoslides} % format 16/9
\documentclass[withvideo]{pharoslides} % format 16/9 + incrustation video

\graphicspath{{./figures/}{../}{../../support/beamer/imgs/}}

%Information to be included in the title page:
\title{Inheritance and Lookup}
\subtitle{4: doesNotUnderstand: aMessage}
\author{Damien Cassou, Stéphane Ducasse and Luc Fabresse}
\institute{http://stephane.ducasse.free.fr}
\date{}
\slidesid{W4S04}

\begin{document}

\frame[plain]{\titlepage}



\begin{frame}[fragile]

\frametitle{Goal}

\begin{itemize}
\item A hook message is sent when the lookup fails
\item Classes can customize the reaction to this failure
\end{itemize}
\end{frame}



\begin{frame}[fragile]

\frametitle{Message Sending}

\begin{columns}

\begin{column}{0.38\textwidth}

\textbf{Sending} a \textbf{message} is a two-step process:

\begin{enumerate}
\item \textbf{look up} the \textbf{method} matching the message
\item execute this method on the \textbf{receiver}
\end{enumerate}
\end{column}


\begin{column}{0.62\textwidth}


\begin{center}
\includegraphics[width=1.0\textwidth]{figures/InheritanceDiagram-sendingMessage.png}\end{center}

\end{column}

\end{columns}

\end{frame}



\begin{frame}[fragile]

\frametitle{When No Method is Found}

\begin{columns}

\begin{column}{0.4\textwidth}

\begin{itemize}
\item if no method is found in the hierarchy, \code{doesNotUnderstand:} is sent to the receiver
\item the initial message is passed as parameter
\end{itemize}
\end{column}


\begin{column}{0.6\textwidth}


\begin{center}
\includegraphics[width=1.0\textwidth]{figures/LookupEssenceWithDoesNotUnderstand.png}\end{center}

\end{column}

\end{columns}

\end{frame}



\begin{frame}[fragile]

\frametitle{When No Method is Found}


\begin{center}
\includegraphics[width=0.7\textwidth]{figures/LookupEssenceWithDoesNotUnderstandFull-no-lines.png}\end{center}

\end{frame}



\begin{frame}[fragile]

\frametitle{Step by Step...}

\begin{columns}

\begin{column}{0.6\textwidth}

\code{node1 coucou: \#stef}

\begin{enumerate}
\item \code{coucou:} looked up in \code{Node}
\item not defined in \code{Node} -\textgreater{} continues in \code{Object}
\item not defined in \code{Object} -\textgreater{} send \code{doesNotUnderstand:} to \code{node1}
\item \code{doesNotUnderstand:} looked up in \code{Node}
\item not defined in \code{Node} -\textgreater{} continues in \code{Object}
\item \code{doesNotUnderstand:} is found and executed
\end{enumerate}
\end{column}


\begin{column}{0.5\textwidth}


\begin{center}
\includegraphics[width=1.2\textwidth]{figures/LookupEssenceWithDoesNotUnderstandFull-no-lines.png}\end{center}

\end{column}

\end{columns}

\end{frame}



\begin{frame}[fragile]

\frametitle{doesNotUnderstand: is a Message}

\begin{itemize}
\item \code{doesNotUnderstand:} is a message
\item any class can implement the corresponding method
\item used for automatic delegation, proxy, distribution
\end{itemize}
\end{frame}



\begin{frame}[fragile]

\frametitle{doesNotUnderstand: and the Debugger}

When no class redefines \code{doesNotUnderstand:}

\begin{itemize}
\item 
\begin{itemize}
\item \code{doesNotUnderstand:} in \code{Object} is executed
\item this method raises a \code{MessageNotUnderstood} exception
\item when not handled, this exception opens a debugger
\end{itemize}

\end{itemize}
\end{frame}



\begin{frame}[fragile]

\frametitle{Catching MessageNotUnderstood Error}

\begin{columns}

\begin{column}{0.6\textwidth}

\code{MessageNotUnderstood} is just an exception, code can handle it:

\begin{listing}{}
Node >> sayHello
  self coucou: #stef

Node >> welcome
  [ self sayHello ]
  on: MessageNotUnderstood
  do: [ Transcript show: 'Something went wrong with a message' ]
\end{listing}
\end{column}


\begin{column}{0.4\textwidth}


\begin{center}
\includegraphics[width=1.3\textwidth]{figures/LookupEssenceWithDoesNotUnderstandFull-no-lines.png}\end{center}

\end{column}

\end{columns}

\end{frame}



\begin{frame}[fragile]

\frametitle{What You Should Know}

\begin{itemize}
\item The lookup sends \code{doesNotUnderstand:} when it can not find a method
\item Each class can implement this method
\item The default implementation of \code{doesNotUnderstand:} raises an exception that can be handled
\end{itemize}
\end{frame}




% \setlength{\textwidth}{\originaltextwidth}
\setbeamertemplate{background canvas}{\insertBorderForHandout}

\begin{frame}[plain]

\begin{minipage}{\originaltextwidth}
\centering
\large


\vspace{2em}

A course by

\vspace{1em}

\hspace{-20px}\includegraphics[height=32px]{inriaLogo}\hspace{3em}\raisebox{7px}{and}\hspace{3em}\raisebox{-6px}{\includegraphics[height=30px]{logoutop}}

\vspace{2em}

in collaboration with

\vspace{1em}

\includegraphics[height=40px]{unisciellogo}\hskip 1.5em%
\raisebox{5px}{\includegraphics[height=30px]{unitlogo}}\hskip 2em%
\raisebox{8px}{\includegraphics[height=24px]{univLilleLogo}}\hskip 2em%
\raisebox{3px}{\includegraphics[height=29px]{logo-IMT}}\hskip 2em%
\raisebox{1px}{\includegraphics[height=32px]{minesDouaiLogo}}

\vspace{2.5em}

\includegraphics[width=50px]{by-nc-nd} \tiny \hskip 0.5em \raisebox{5px}{Inria 2016}

\medskip

\tiny
Except where otherwise noted, this work is licensed under CC BY-NC-ND 3.0 France

\url{https://creativecommons.org/licenses/by-nc-nd/3.0/fr/} 

\end{minipage}
\end{frame}

\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
