Builder
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.
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's assume I'm really lazy, and would like to schedule emails to be sent while I'm actually biking around the neighborhood.
The actual scheduling logic will be postponed to Chapter 8, Threads and Coroutines, and Chapter 9, Designed for Concurrency, which discuss scheduling and concurrency. For now...