October 2019
Intermediate to advanced
434 pages
11h 54m
English
The Builder pattern helps us to configure different representations of a class, typically, for classes that have many optional parameters. In the world of Java, this is often done by creating an inner class called Builder for whichever type we are looking to configure. Client code then sets fields on the Builder, and eventually calls a build() method. Within build(), the Builder can create an instance of the desired class using any fields set on the builder, and using sensible defaults for any of the optional fields. This enables client code to ignore any fields that aren't relevant.
Let's take an example of what this looks like in Java so that we can compare it effectively to our Kotlin implementation in ...
Read now
Unlock full access