Summary

We looked at three creational design patterns—Singleton, Factory method, and builder— specifically the rationale behind them and the Java implementations. We also learnt about a special singleton—Null Object. We saw how Scala helps avoid null using Options. We looked at multiple Scala idioms with respect to Options and saw how Options as a container theme helps. We also saw the special apply method and learned how this syntactic sugar sweetens the code. Finally we looked at builders—a design pattern for creating objects with many attributes. We also saw how Scala's case classes help us with the creation of objects having many attributes. Take a deep breath readers, grab a cup of your favorite hot beverage and settle down to read about ...

Get Scala Functional Programming Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.