

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

\begin{document}

\frame[plain]{\titlepage}



\begin{frame}[fragile]

\frametitle{Class Methods}

\begin{enumerate}
\item in Pharo, everything is an object
\item objects can receive messages
\item classes are objects too
\end{enumerate}

Classes can receive messages
\end{frame}



\begin{frame}[fragile]

\frametitle{Examples}

\begin{listing}{}
Time now
> 9:18:36.304688 pm
\end{listing}

The message \code{now} is sent to the class \code{Time}

\begin{listing}{}
Date today
> 29 July 2015
\end{listing}

The message \code{today} is sent to the class \code{Date}
\end{frame}



\begin{frame}[fragile]

\frametitle{Examples}

\begin{listing}{}
FileLocator workingDirectory
\end{listing}

\begin{listing}{}
ZnEasy getPng: 'http://pharo.org/web/files/pharo.png'
\end{listing}

\begin{listing}{}
ZnServer startDefaultOn: 8080
\end{listing}
\end{frame}



\begin{frame}[fragile]

\frametitle{Class Methods are Defined on Class Side}

Note the \code{Class} button pressed!


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

\end{frame}



\begin{frame}[fragile]

\frametitle{Common Mistake}

\begin{listing}{}
Counter class >> withValue: anInteger
   self new
      value: anInteger;
      yourself
\end{listing}

\code{Counter withValue: 10} returns the class \code{Counter} instead of a new instance
\end{frame}



\begin{frame}[fragile]

\frametitle{Why?}

\begin{listing}{}
Counter class >> withValue: anInteger
   self new
      value: anInteger;
      yourself
\end{listing}

is equivalent to

\begin{listing}{}
Counter class >> withValue: anInteger
   self new
      value: anInteger;
      yourself.
   ^ self
\end{listing}

\code{self} here is the class \code{Counter} (the receiver of the message)
\end{frame}



\begin{frame}[fragile]

\frametitle{Solution}

\begin{listing}{}
Counter class >> withValue: anInteger
   ^ self new
      value: anInteger;
      yourself
\end{listing}
\end{frame}



\begin{frame}[fragile]

\frametitle{Summary}

\begin{itemize}
\item Classes are objects
\item Messages can be sent to classes too
\item Class-side methods are no different from other methods
\item Most class-side methods create new instances
\item To define a class-side method, press the \code{class} button
\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:
