February 2016
Intermediate to advanced
382 pages
8h 1m
English
There are some different variations of the factory design patterns. In all cases, though, the purpose is generally the same—hide creation complexity. In the next subsections, we will briefly mention two of the other factory design patterns: static factory and simple factory.
The static factory could be represented as a static method, which is a part of the base class. It is called to create concrete instances, which extend the base class. One of the biggest drawbacks here, however, is that if another extension of the base class is added, the base class (because of the static method) also has to be edited. Let's show a simple example from the world of the animals:
trait Animal class Bird extends Animal ...
Read now
Unlock full access