Skip to Content
Good Code, Bad Code
book

Good Code, Bad Code

by Tom Long
August 2021
Intermediate to advanced
376 pages
11h 2m
English
Manning Publications
Content preview from Good Code, Bad Code

Appendix C. Extra code examples

C.1 The builder pattern

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

The Art of Clean Code

The Art of Clean Code

Christian Mayer
Clean Code Cookbook

Clean Code Cookbook

Maximiliano Contieri
Five Lines of Code

Five Lines of Code

Christian Clausen

Publisher Resources

ISBN: 9781617298936Publisher SupportOtherPublisher WebsitePurchase Link