wip on state pattern

This commit is contained in:
Claudio Maggioni 2022-10-19 11:35:50 +02:00
parent b0b86d61e8
commit 69017acbb5
2 changed files with 40 additions and 13 deletions

Binary file not shown.

View File

@ -1,14 +1,19 @@
% vim: set ts=2 sw=2 et tw=80: % vim: set ts=2 sw=2 et tw=80:
\documentclass[12pt,a4paper]{scrartcl} \documentclass[10pt,a4paper]{scrartcl}
\usepackage[utf8]{inputenc} \usepackage[utf8]{inputenc}
\usepackage[margin=2.5cm]{geometry} \usepackage[margin=2.25cm]{geometry}
\usepackage{hyperref} \usepackage{hyperref}
\usepackage{listings} \usepackage{listings}
\usepackage{xcolor} \usepackage{xcolor}
\usepackage{lmodern} \usepackage{lmodern}
\usepackage{listings} \usepackage{listings}
\setlength{\parindent}{0cm} \setlength{\parindent}{0cm}
\setlength{\parskip}{0.3em}
\hypersetup{pdfborder={0 0 0}}
\usepackage[nomessages]{fp}
\renewcommand*{\titlepagestyle}{empty}
\lstset{ \lstset{
basicstyle=\small\ttfamily, basicstyle=\small\ttfamily,
@ -30,9 +35,15 @@
\author{Volodymyr Karpenko \and Claudio Maggioni} \author{Volodymyr Karpenko \and Claudio Maggioni}
\begin{document} \begin{document}
\begin{titlepage}
\maketitle \maketitle
\pagenumbering{roman}
\tableofcontents
\lstlistoflistings
\end{titlepage}
\section{Project selection process} \section{Project selection process}
\pagenumbering{arabic}
We need to find a project that is a single unit in terms of compilation We need to find a project that is a single unit in terms of compilation
modules\footnote{A problem for Pattern4J as compiled \texttt{.class} files are modules\footnote{A problem for Pattern4J as compiled \texttt{.class} files are
@ -72,8 +83,8 @@ interfaces to allow other modules to be plugged-in. Additionally, the
\textit{core} module implements the tokenizer and low-level abstractions to work \textit{core} module implements the tokenizer and low-level abstractions to work
with the JSON format. with the JSON format.
We chose to analyze version 2.13.4 of the module (corresponding to the code We chose to analyze version 2.13.4 of the module (i.e.\ the code
under the git tag \texttt{jackson-core-2.13.4}) because it is the latest stable under the git tag \texttt{jackson-core-2.13.4}) because it is the latest stable
version available at the time of writing. version available at the time of writing.
\section{Analysis Implementation} \section{Analysis Implementation}
@ -156,6 +167,7 @@ produced the following results:
bitmask \texttt{protected int} fields, which are then directly accessed by bitmask \texttt{protected int} fields, which are then directly accessed by
the constructor of the \textbf{TokenStreamFactory} concrete implementation the constructor of the \textbf{TokenStreamFactory} concrete implementation
to build; to build;
\marginpar[right text]{\color{white}\url{https://youtu.be/72b2nH-kdbU}}
\item[JsonFactoryBuilder] an concrete factory implementation of \item[JsonFactoryBuilder] an concrete factory implementation of
\textbf{TSFBuilder} that builds \textbf{JsonFactory} instances; \textbf{TSFBuilder} that builds \textbf{JsonFactory} instances;
\item[util.ByteArrayBuilder] provides facilities to build \texttt{byte[]} objects \item[util.ByteArrayBuilder] provides facilities to build \texttt{byte[]} objects
@ -171,27 +183,43 @@ produced the following results:
\subsection{Adapter Pattern} \subsection{Adapter Pattern}
TBD TBD
\subsection{Decorator Pattern}
Only in Pattern4j
\subsection{Bridge Pattern} \subsection{Bridge Pattern}
TBD TBD
\subsection{Composite Pattern} \subsection{Composite Pattern}
TBD None found
\subsection{Facade Pattern} \subsection{Facade Pattern}
TBD TBD -- \textit{Pattern4} does not detect this pattern
\subsection{Proxy Pattern} \subsection{Proxy Pattern}
TBD None found
\section{Behavioral Patterns} \section{Behavioral Patterns}
\subsection{Command Pattern} \subsection{Command Pattern}
TBD None found
\subsection{Observer Pattern} \subsection{Observer Pattern}
TBD None found
\subsection{Strategy Pattern} \subsection{Strategy Pattern}
TBD None found
\subsection{State Pattern}
Among the design patterns \textit{Pattern4} detects, the state pattern is
detected in 5 classes. The state pattern is a variation of the strategy pattern
where the concrete strategy used by the matching context is determined by the
state of a finite state machine the context class implements. In other words,
the state pattern chooses the concrete strategy to use through the state of the
context.
util.DefaultPrettyPrinter delegate pattern maybe, but no state
TBD instances and examples
\subsection{Template Method Pattern} \subsection{Template Method Pattern}
Due to the extendibility of Jackson, it is of no surprise that the template Due to the extendibility of Jackson, it is of no surprise that the template
@ -202,7 +230,7 @@ correctly detects several instances of the pattern, namely
\textbf{JsonParser}, \textbf{base.ParserBase}, \textbf{base.GeneratorBase}, \textbf{JsonParser}, \textbf{base.ParserBase}, \textbf{base.GeneratorBase},
\textbf{base.ParserMinimalBase}. All these classes implement several concrete \textbf{base.ParserMinimalBase}. All these classes implement several concrete
\texttt{public} methods throwgh the use of \texttt{protected abstract} methods. \texttt{public} methods throwgh the use of \texttt{protected abstract} methods.
Although the concrete (i.e. the template) methods are usually not vary complex Although the concrete (i.e.\ the template) methods are usually not vary complex
(as the pattern example shown in class), they still follow the principles of the (as the pattern example shown in class), they still follow the principles of the
template method pattern. We show as an example some template methods found in template method pattern. We show as an example some template methods found in
\textbf{base.ParserBase}: \textbf{base.ParserBase}:
@ -238,9 +266,8 @@ Here the pattern is slightly modified by providing a default implementation of
override the method with a body first calling \texttt{super()} and then adding override the method with a body first calling \texttt{super()} and then adding
additional buffer release code after. additional buffer release code after.
\subsection{Visitor Pattern} \subsection{Visitor Pattern}
TBD None found
\end{document} \end{document}