dog

A Scala Factory Pattern example

Here’s a small example of how to create a Factory Pattern in Scala. In the Scala Cookbook I created what some people might call a simple factory and/or static factory, so the following code is a much better implementation of a true OOP Factory Pattern.

The factory classes

I don’t have too much time to explain the code today, but here are the classes that make up the factory, including a set of “animal” classes along with a DogFactory and CatFactory that extend an AnimalFactory trait:

Good design: Quantity leads to quality (and iteration speed is vital)

When I saw this tweet this morning:

[DOG MAGICIAN] think of a color, any color ... is it ... gray?

[OTHER DOG] oh my GOD

I knew that I loved the joke, but I didn’t like the presentation. I wanted to put the joke on Facebook, but I know that people like images more than they like text, so I made a second cup of coffee and began putting the text on an image.

Rocky and a bone

While I’m sharing photos of Siberian Huskies I’ve known and loved, here’s one of Rocky working on a bone. My wife originally found him stuck in a cinder block in Virginia when he was probably about 18” long, and he became the first husky we’d know. He became famous for destroying furniture, howling, and running around saying words like “Oprah” and “Geraldo.”

Running on all fours

Over the last few years I’ve had a few dreams where I become lucid in a dream and find myself running on all fours. When this happens I think, “Well, this is odd, why am I running like this?” I then try to stand up, but I can’t. Typically I just keep running like that until I fade into the blackness of unconscious sleep.

One time when this happened I found myself running on all fours down a sidewalk, with a street to my left. Just as I was thinking about trying to stand upright I heard a noise to my right. I stopped in place, saw something small moving, and more or less against my will I began running towards the thing that moved. It suddenly occurred to me that the reason I was running on all fours was that I was a dog. “I” had my normal “I know I’m Alvin” consciousness, but I was in a dog’s body and I didn’t seem to have much control over the situation, I was just a passenger.