

% 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{Pharo Object Model in a Nutshell}
\subtitle{Elegance and Simplicity}
\author{Damien Cassou, Stéphane Ducasse and Luc Fabresse}
\institute{http://stephane.ducasse.free.fr}
\date{}
\slidesid{W1S04}

\begin{document}

\frame[plain]{\titlepage}



\begin{frame}[fragile]

\frametitle{Only Objects, Messages, ...}

\begin{itemize}
\item \textbf{Objects}: mouse pointer, booleans, arrays, numbers, strings, windows, scrollbars, canvas, files, trees, compilers, sound, url, socket, fonts, text, collections, stack, shortcut, streams...
\item \textbf{Messages} sent to these objects: \code{size}, \code{+}, \code{at:put:}, \code{do:}, ...
\end{itemize}
\end{frame}



\begin{frame}[fragile]

\frametitle{... and Block Closures}

\begin{itemize}
\item Messages are \textbf{what} (intent)
\item Methods are \textbf{how} to do it
\item Closures are kind of anonymous methods
\item Closures are called \textbf{blocks} in Pharo
\end{itemize}

\begin{listing}{}
4 timesRepeat: 
	[ Transcript show: 'Hello World' ]
\end{listing}

\begin{itemize}
\item \textbf{{[} ... {]}} delimits a block
\end{itemize}
\end{frame}



\begin{frame}[fragile]

\frametitle{A Simple and Uniform Model}

\begin{itemize}
\item \textbf{Everything} is an object, instance of a class
\begin{itemize}
\item Classes and messages are objects too!
\end{itemize}

\item All computations between objects are done via \textbf{message passing}
\item We use the term \textbf{sending a message} because:
\begin{itemize}
\item methods are always looked up dynamically
\item only late binding, only virtual calls
\end{itemize}

\item Only \textbf{ONE} method lookup for all objects
\end{itemize}
\end{frame}



\begin{frame}[fragile]

\frametitle{Pharo Object Model}

\begin{itemize}
\item Instance variables are protected:
\begin{itemize}
\item private to the object
\item accessible from subclasses
\end{itemize}

\item Methods are public and virtually bound
\item Single inheritance between classes
\end{itemize}
\end{frame}



\begin{frame}[fragile]

\frametitle{Messages}

Computation between objects is done via message sends

Example of the cross product of two points:

\begin{listing}{}
(point1 x * point2 y) - (point1 y * point2 x)
\end{listing}
\end{frame}



\begin{frame}[fragile]

\frametitle{Object Creation: Creating a Point}

A new object can be created by sending a message to another object

\begin{listing}{}
10@20
\end{listing}

A new \code{Point} object is created by:

\begin{itemize}
\item sending the message \code{@}
\item to the object \code{10} (\code{SmallInteger})
\item with the argument \code{20} (\code{SmallInteger})
\end{itemize}
\end{frame}



\begin{frame}[fragile]

\frametitle{Object Creation: Creating a String}

\begin{listing}{}
'Pharo', ' is Cool'
> 'Pharo is Cool'
\end{listing}

A new \code{String} is created as the concatenation of two strings by:

\begin{itemize}
\item by sending the message \code{,}
\item to the string \code{'Pharo'}
\item with the string \code{' is Cool'} as argument
\end{itemize}
\end{frame}



\begin{frame}[fragile]

\frametitle{Object Creation}

Sending the messages \code{new} and \code{new:} to a class

\begin{listing}{}
Monster new
> aMonster
\end{listing}

\begin{listing}{}
Array new: 6
> #(nil nil nil nil nil nil)
\end{listing}

Here we get an array of size 6
\end{frame}



\begin{frame}[fragile]

\frametitle{Object Creation}

Sending instance-creation messages to a class

\begin{listing}{}
Tomagoshi withHunger: 10
\end{listing}

This executes a class method
\end{frame}



\begin{frame}[fragile]

\frametitle{Less is More :)}

\begin{itemize}
\item No constructors
\item No static methods
\item No type declarations
\item No interfaces
\item No package/private/protected modifiers
\item No parametrized types
\item No boxing/unboxing
\item still \textbf{really} powerful :)
\end{itemize}
\end{frame}



\begin{frame}[fragile]

\frametitle{Summary}

\begin{itemize}
\item Everything is an object
\item Computation is done via messages sent to objects
\item Methods are late bound (looked up dynamically in the inheritance chain)
\item Blocks are kind of anonymous methods
\item Instances are created by sending messages to other objects, or classes
\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:
