Sometimes, our objects are very simple, and have only one constructor, be it an empty or non-empty one. But sometimes, their creation is very complex, and based on a lot of parameters. We've seen one pattern already that provides a better constructor—the Static Factory Method design pattern. Now, we'll discuss Builder design pattern, which is somewhat similar and somewhat different.
Builder
Composing an email
As a software architect, one of my main channels of communication is email. Probably this is true of most software development roles.
An email has the following:
- An address (at least one is mandatory)
- CC (zero or more, optional)
- Title (optional)
- Body (optional)
- Attachment (zero or more, optional)
Let...