August 2021
Intermediate to advanced
376 pages
11h 2m
English
Chapter 7 contained a simplified implementation of the builder pattern. In reality engineers often make use of a number of techniques and language features when implementing the builder pattern. Listing C.11, demonstrates a more complete implementation of the builder pattern in Java. Some things to note in this implementation are as follows:
The TextOptions class constructor is private to force other engineers to use the builder pattern.
The TextOptions class constructor takes an instance of Builder as a parameter. This makes the code a little easier to read and maintain because it avoids very long lists of parameters and arguments.
The TextOptions class provides a toBuilder() method ...