

% 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{Essence of Dispatch}
\subtitle{}
\author{Damien Cassou, Stéphane Ducasse and Luc Fabresse}
\institute{http://stephane.ducasse.free.fr}
\date{}
\slidesid{W3S02}

\begin{document}

\frame[plain]{\titlepage}



\begin{frame}[fragile]

\frametitle{Remember: Implementing not in Two Methods}


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

\end{frame}



\begin{frame}[fragile]

\frametitle{Stepping Back}

\begin{itemize}
\item Let the receiver decide
\item Do not ask, tell
\end{itemize}
\end{frame}



\begin{frame}[fragile]

\frametitle{Ok So What?}

\begin{itemize}
\item You will probably never implement \code{Booleans} in the future
\item So is it really that totally useless?
\item What is the lesson to learn?
\end{itemize}
\end{frame}



\begin{frame}[fragile]

\frametitle{Message Sends Act as Case Statements}

\begin{itemize}
\item Message sends act as case statements
\item But with messages, the case statement is \textbf{dynamic} in the sense that it depends on the objects to which the message is sent
\end{itemize}
\end{frame}



\begin{frame}[fragile]

\frametitle{Sending a Message is Making a Choice}

\begin{itemize}
\item Each time you send a message, the execution \textbf{selects the right} method depending on the class of the receiver
\item Sending a message is a \textbf{choice} operator
\end{itemize}
\end{frame}



\begin{frame}[fragile]

\frametitle{Question}

Can we implement the same implementation for Not in only one class?

\begin{itemize}
\item No
\item NO
\item NO!
\end{itemize}
\end{frame}



\begin{frame}[fragile]

\frametitle{Classes Play Case Roles}

\begin{itemize}
\item To activate the choice operator we must have choices: classes
\item A class represents a case
\end{itemize}
\end{frame}



\begin{frame}[fragile]

\frametitle{A Class Hierarchy is a Skeleton for Dynamic Dispatch}

Compare the solution with one class vs. a hierarchy

\begin{itemize}
\item More modular
\item Hierarchy provides a way to specialize behavior
\item You only focus on one class at a time
\end{itemize}


\begin{center}
\includegraphics[width=0.8\textwidth]{figures/Design-FatVsDispatch.png}\end{center}

\end{frame}



\begin{frame}[fragile]

\frametitle{Advantages of Class Hierarchy}


\begin{center}
\includegraphics[width=0.9\textwidth]{figures/Design-FatVsDispatchWithPackages.png}\end{center}


More modular: We can package different classes in different packages
\end{frame}



\begin{frame}[fragile]

\frametitle{Let the Receiver Decide}

\begin{itemize}
\item Sending a message lets the receiver decide
\item Client does not have to decide
\item Client code is more declarative: give orders
\item Different receivers may be substitued dynamically
\end{itemize}
\end{frame}



\begin{frame}[fragile]

\frametitle{Avoid Conditionals}

\begin{itemize}
\item Use objects and messages, when you can
\item The execution engine acts as a conditional switch: Use it!
\item Check the AntiIfCampaign
\end{itemize}
\end{frame}



\begin{frame}[fragile]

\frametitle{Summary: Cornerstone of OOP}

\begin{itemize}
\item Let the receiver decide
\item Message sends act as potential dynamic conditionals
\item Class hierarchy: a skeleton for dynamic dispatch
\item Avoid conditionals
\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:
