While working on a new Scala application recently, the alarms started going off in my head, saying "You need to use the Factory Pattern here." That's when things got interesting.
Just exactly how do you implement the Factory Pattern in Scala?
Here's a simple, quick example.
(1) The interface
Sparing you all the experiments I went through, let's assume you want a factory that produces animals like this: