Java Design Patterns – Naming the Pattern for Passing One Object to a Constructor

design-patternsjavanamingobject-orientedterminology

If you have a constructor that takes a lot of parameters, like this:

  public OrgUnitsHalRepresentation(List<OrgUnitSummaryHalRepresentation> orgUnitSummaryHalRepresentationList,
  int count, int providedCount, int total, int page, int filterLimit, boolean hasNextPage, boolean isDefaultCount)

You can use a separate class that takes nothing in the constructor and set these parameters using setters and pass in this into the constructor instead:

public OrgUnitsHalRepresentation(Pagination(Name of pattern) p)

Does this have a name so that I can use it in my class name?

Best Answer

This is the Parameter Object Design Pattern (or Argument Object), the related Refactoring is called Introduce Parameter Object.