\subsection{\refactoring{Introduce Parameter Object}}
This refactoring wraps a set $P$ of parameters of a method $m$ into a single parameter $n$ of type $w$, where $w$ is a newly created wrapper class containing fields corresponding to all the parameters in $P$. Implemented in \sourcelink{IntroduceParameterObject/IntroduceParameterObject.jrag}; see Algorithm \ref{alg:IntroduceParameterObject}.

\begin{algorithm}[p]
\caption{$\refactoring{Introduce Parameter Object}(m : \type{Method}, P : \settp{\type{Parameter}}, w : \settp{Name}, n : \settp{Name})$}
\label{alg:IntroduceParameterObject}
\begin{algorithmic}[1]
\REQUIRE Java $\setminus$ variable arity parameters
\ENSURE Java $\cup$ locked names
\medskip
\STATE \assert $m$ has a body
\STATE \assert the parameters in $P$ are in contiguous positions $i, \ldots, i+k$
\STATE $W \leftarrow$ new class containing fields for all the $P$ and a standard constructor to initialise them
\STATE $\refactoring{Insert Type}(\util{hostType}(m), W)$
\STATE $\util{lockMethodCalls}(\util{name}(m))$
\FORALL{relatives $r$ of $m$}
  \STATE \assert $r$ has no parameter or local variable with name $n$
  \STATE $[p_1;\ldots;p_n] \leftarrow \text{parameters of $r$}$
  \STATE $p \leftarrow \text{new parameter of type $W$ and name $n$}$
  \STATE replace parameters $p_i, \ldots, p_{i+k}$ with $p$
  \FORALL{$j\in\{i, \ldots, i+k\}$}
    \STATE $v_j \leftarrow \text{new variable of same name, type, and finality as $p_j$}$
    \STATE insert assignment from $p.f_j$ to $v_j$ at beginning of $m$
  \ENDFOR
  \FORALL{calls $c$ to $r$}
    \STATE $[a_1;\ldots;a_n] \leftarrow \text{arguments of $c$}$
    \STATE replace arguments $a_i, \ldots, a_{i+k}$ with \code{new }$W$\code{(}$a_i$\code{,}\ldots\code{,}$a_{i+k}$\code{)}
  \ENDFOR
\ENDFOR
\end{algorithmic}
\end{algorithm}

Note that we need to perform the transformation for all relatives of $m$, \emph{i.e.} for all methods $r$ such that there exists a method $m'$ with $m<:^*m'$ and $r<:^*m'$. We also lock all calls to methods of the same as $m$ in the whole program; this ensures that if overloading resolution changes due to the transformation, the name binding framework will insert appropriate casts to rectify the situation.

Note: the implementation actually: eliminates variable arity parameter for this method and adjusts all calls; does not require $p_i$ to be contiguous and adds new argument at the beginning. (This can be unsound for parameters with side effects!!!)
