The syntax of Java language doesn’t allow you to declare a method with a predefined value
for a parameter. Probably the best option to achieve default method parameters in Java is
by using the method overloading. Method overloading allows you to declare several methods
with the same name but with a different number of parameters. But the main problem with
method overloading as a solution for default parameter values reveals itself when a method
accepts multiple parameters. Creating an overloaded method for each possible combination of
parameters might be cumbersome. To deal with this issue, the Parameter Object pattern is used.
## Explanation
The Parameter Object is simply a wrapper object for all parameters of a method.
It is nothing more than just a regular POJO. The advantage of the Parameter Object over a
regular method parameter list is the fact that class fields can have default values.
Once the wrapper class is created for the method parameter list, a corresponding builder class
is also created. Usually it's an inner static class. The final step is to use the builder
to construct a new parameter object. For those parameters that are skipped,
their default values are going to be used.
**Programmatic Example**
Here's the simple `SearchService` class where Method Overloading is used to default values here. To use method overloading, either the number of arguments or argument type has to be different.
```java
public class SearchService {
//Method Overloading example. SortOrder is defaulted in this method
public String search(String type, String sortBy) {