What it is not so good for

Depending on the amount of shared data, sometimes the number of distinct shared objects could dramatically grow and not bring too much benefit. Moreover, it can complicate the factory and its usage. Multithreaded applications need extra care while working with factories. Last but not least, the developers need to be really careful while using shared objects, as any change in them could affect the entire application. Luckily, in Scala, this is less of a concern due to immutability.

Get Scala Design Patterns - Second Edition 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.