- You want encapsulation
- You have too many parameters for your class constructor.
- You want immutability
Add everything to the constuctor.
We've got encapsulation.
We can validate everything once
We've got immutability
Too many parameters! You'll get lost creating the instance in the first place.
Create getters and setters.
### Benefit
We get help from intellisense.
But now we've lost encapsulation. We can include a couple of parameters and completely ignore the other parameters in our object.
And now we are no longer able to ensure the state of our object. It can be anything.
Make another class which interacts with our object, and through that object only, build the class that we need.
See below for example: