Parameter Object (PO)


This pattern is unrestricted; it is used within any architectural layer.


A PED Parameter Object (PO) is a continuation of a pattern in use for twenty years. Martin Fowler expressed the pattern in 1999:

You have a group of [method] parameters that naturally go together; replace them with an object.

The pattern promotes software adaptability; it encourages method signature durability while enabling future functional extensions. That is, you can add values passed to a method without altering the method signature.

Some developers express concern when a PO begins to contain behavior other than accessor/mutator methods.  That is, a discomfort with encapsulating logic in a PO that could be placed in a non-PO. To the contrary, Kent Beck clarifies that emerging encapsulation should be encouraged:

“…see if there are bits of code using only the fields in the parameter object you could turn into methods on the parameter object.”

As an aside, fluent POs are a useful pattern for legacy code rescue initiatives.

Structural Characteristics




 Extend Base Class Optional  
 No-arg Constructor Optional  
 CDI Scoping N  
 Instance State Y  
 Static Public Methods (enum) N  
 Fluent Methods Y  
 Delegate to Helper N  
 Worker-thread Safe Optional 1.
  1. A PO in a multicore context requires intentional design attention.
Source Example