The preceding builder design pattern looks nice and clear, but it requires writing some extra code and creating boilerplate. Moreover, it requires us to have mutable fields in the PersonBuilder class, which is against some of the principles in Scala.
Scala has case classes, which make the implementation of the builder pattern much simpler. Here is what it will look like:
case class Person( firstName: String = "", lastName: String = "", age: Int = 0)
The use of this case class is similar to how the preceding ...