\documentclass[a4,compress]{beamer}

\usepackage[latin1]{inputenc}
\usepackage[english]{babel}

\usepackage{xspace}

\usetheme{Inria}
\setcounter{tocdepth}{2}

\title{Traits under the grill}

\author{Guillaume Libersat (glibersat@sigill.org)}
\institute{Pr. Stéphane Ducasse -- ADAM/RMoD Team}
\date{\today}

\pgfdeclareimage[height=1.0cm]{lifl}{lifl}
\pgfdeclareimage[height=1.0cm]{ustl}{ustl}
\logo{ \pgfuseimage{ustl} \\ \pgfuseimage{lifl} }

\bibliographystyle{alpha}

\begin{document}

\maketitle

\frame
{
  \tableofcontents  
}

\section{Traits ?}

\subsection{Context}

\frame
{
  \frametitle{Context}
  
  Object-Oriented Programming (OOP)
  \begin{itemize}
  \item Inheritance is fundamental
  \item No ideal solution
  \end{itemize}

\bigskip
\pause
  3 main approaches
  \begin{itemize}
  \item Single inheritance
  \item Multiple inheritance
  \item Mixins
  \end{itemize}
}

\subsection{State of the art}

\subsubsection{Single Inheritance}

\frame
{
  \frametitle{Single inheritance}

  Single inheritance
  \begin{itemize}
  \item Simple, easy to implement
  \item Used in many programming languages
  \item Restricting, lack of expressivity (duplication, interfaces, ...)
  \end{itemize}

}

\frame
{
  \frametitle{Single inheritance : example}

  \includegraphics<1>[height=6cm]{images/single1.png}
  \includegraphics<2>[height=6cm]{images/single2.png}
  \includegraphics<3>[height=6cm]{images/single3.png}
}

\subsubsection{Multiple inheritance}

\frame
{
  \frametitle{Multiple Inheritance}

  Multiple inheritance
  \begin{itemize}
  \item<1-> Very expressive
  \item<2-> Create complex problems
    \begin{itemize}
      \item<3-> Diamond problem (or ``fork-join'' problem)
      \item<3-> Super-class references
      \item<3-> Algorithm for linearization
    \end{itemize}
  \end{itemize}

\pause
\pause
\pause

\bigskip
  Conclusion :
  \begin{quote}
    ``Multiple inheritance is good, but there is no good way to do
    it'' ~\cite{Cook87a}
  \end{quote}

}

\frame
{
  \frametitle{Multiple inheritance : example}

  \includegraphics<1>[height=6cm]{images/multiple1.png}
  \includegraphics<2>[height=6cm]{images/multiple2.png}
  \includegraphics<3>[height=6cm]{images/multiple3.png}
}


\subsubsection{Interlude}

\frame
{
  \frametitle{Interlude : Psychoanalyze ?}

  So...
  \begin{itemize}
  \item No satisfying solution !
  \item Need to rethink some aspects
  \end{itemize}

\bigskip
\pause

  Problem, schizophrenia ?
  \begin{itemize}
  \item Classes used for instantiation
  \item Classes used for code reuse
  \end{itemize}

\pause
\bigskip
  Conclusion
  \begin{itemize}
  \item Need of specific units for code reuse
  \item Classes = only generators
  \end{itemize}
}

\subsubsection{Mixins}

\frame
{
  \frametitle{Mixin}

  Mixin ?
  \begin{itemize}
  \item Class dedicated to store shared code
  \item Linerization at compile-time
  \end{itemize}
    
\bigskip
\pause

  Problems
  \begin{itemize}
  \item Make use of inheritance operator
  \item Implicit conflict resolution
  \item No control over composition
  \item Fragile hierarchy
  \end{itemize}

}


\frame
{
  \frametitle{Mixin : example}

  \includegraphics<1>[height=6cm]{images/mixin1.png}
  \includegraphics<2>[height=6cm]{images/mixin2.png}
  \includegraphics<3>[height=6cm]{images/mixin3.png}
  \includegraphics<4>[height=6cm]{images/mixin4.png}
  \includegraphics<5>[height=6cm]{images/mixin5.png}
  \includegraphics<6>[height=6cm]{images/mixin6.png}
  
}

\subsection{Traits}

\subsubsection{Overview}

\frame
{
  \frametitle{Traits}

  Traits
  \begin{itemize}
  \item Same idea and goals as mixins
  \item Fix problems of mixins
  \end{itemize}

\pause
\bigskip

  Design principles
  \begin{itemize}
  \item Simplicity
  \item Composer is empowered
  \item No impact over performances
  \end{itemize}
}


\frame
{
  \frametitle{Traits in a nutshell}

  Trait ?
  \begin{itemize}
  \item<1-> Set of methods (small class)
  \item<2-> Stateless : no instance variables
  \item<3-> Specify a set of required methods
  \end{itemize}

\bigskip
\pause
\pause
\pause

  Properties
  \begin{itemize}
  \item Composition (class + traits)
  \item Flattening
\pause
  \item Aliasing
  \item Explicit resolution
  \end{itemize}
}

\subsubsection{Examples}

\frame
{
  \frametitle{Traits : Composition example}

  \includegraphics<1>[height=12cm]{images/traits1.png}
  \includegraphics<2>[height=12cm]{images/traits2.png}
  \includegraphics<3>[height=12cm]{images/traits3.png}
  \includegraphics<4>[height=12cm]{images/traits4.png}
}

\frame
{
  \frametitle{Traits : conflict resolution}

  \includegraphics<1>[height=13cm]{images/trait_conflict1.png}
  \includegraphics<2>[height=13cm]{images/trait_conflict2.png}
  \includegraphics<3>[height=13cm]{images/trait_conflict3.png}
  \includegraphics<4>[height=13cm]{images/trait_conflict4.png}
  \includegraphics<5>[height=13cm]{images/trait_conflict5.png}
  \includegraphics<6>[height=13cm]{images/trait_conflict4.png}
  \includegraphics<7>[height=13cm]{images/trait_conflict6.png}
}

\subsubsection{Validation}

\frame
{
  \frametitle{Validation}

  Validation
  \begin{itemize}
  \item Implemented in Squeak
\pause
  \item ``Collection'' hierarchy refactored
    \begin{itemize}
    \item 21 classes (code duplication, ...)
\pause
    \item Results :
      \begin{itemize}
      \item 48 traits, 567 methods
      \item 12\% lignes of code saved
\pause
      \item Better maintainability
      \item Fully backward compatible
      \item No performance penalty
      \end{itemize}
    \end{itemize}
  \end{itemize}
}

\subsubsection{Incarnations}

\frame
{
  \frametitle{Incarnations}

  In fact, 3 main incarnations
  \begin{enumerate}
  \item Stateless traits ~\cite{scharli-traits}
    \begin{itemize}
    \item What we've seen
    \end{itemize}

\bigskip
\pause
  \item Statefull traits ~\cite{statefull}
    \begin{itemize}
    \item Add state (instance variables)
    \item Brings a lot of problems too
    \end{itemize}

\bigskip
\pause
  \item Freezable traits ~\cite{freezable}
    \begin{itemize}
    \item Enhance model with visibilty
    \end{itemize}
  \end{enumerate}

}
\subsection{Conclusion}

\frame
{
  \frametitle{Conclusion}

  So, Traits
  \begin{itemize}
  \item Ideal extension for single inheritance
  \item Doesn't break compatibility
  \item Does not suffer from multiple inheritance problems
  \end{itemize}

\pause
\bigskip

  Great interest from community
  \begin{itemize}
  \item Perl 6
  \item Fortress
  \item Java, C\#
  \item Scala
  \end{itemize}
}

\section{My work}

\subsection{Overview}

\frame
{
  \frametitle{Now, my work}

  3 steps
  \begin{enumerate}
  \item Evaluate/Update
  \item Re-factor some apps
  \item Observe and fix problems
  \end{enumerate}
}

\subsection{Evaluation}
\frame
{
  \frametitle{Evaluation of traits}

  Evaluate
  \begin{itemize}
  \item External point of view
  \item Try to follow some open questions
  \end{itemize}

  \pause
  \bigskip

  Update
  \begin{itemize}
  \item Look for new papers
  \item Check for related works
  \end{itemize}

}

\subsection{Re-factoring}
\frame
{
  \frametitle{Re-factoring}

  4 libraries/apps
  \begin{itemize}
  \item Different languages
  \item Heterogeneous kind of software
    \begin{itemize}
    \item ``Collection'' library
    \item ``iCal'' library
    \item ...
    \end{itemize}

  \end{itemize}
  
}


\subsection{Expectations}


\frame
{
  \frametitle{Expectations}

  What we expect
  \begin{itemize}
  \item Stress the concept
  \item Find common problems
  \end{itemize}

\pause
\bigskip

  What we hope
  \begin{itemize}
  \item Fix most of them
  \item Submit a new model
\pause
  \item Implement a proof of concept
  \item Re-factor a library
  \end{itemize}
}

\frame
{
  \frametitle{For further reading...}

  \bibliography{workshop}

}

\section{Questions}

\frame
{
  \frametitle{Questions ?}

\Large
  \begin{center}
    Thanks !
  \end{center}

\bigskip

\LARGE
  \begin{center}
    Any questions ?
  \end{center}


}

\end{document}
