Breaking up with Singleton

Have you ever secretly come to really dislike someone?


At first you think they’re great. You might even want to get closer. Then, after spending time with them, you realize they are a little obnoxious. Then, bit by bit, you start avoiding them whenever you can.

Finally, the day comes, when a friend quietly whispers “You know, I can’t stand that person”.

Reaction: Relief

Suddenly you realize you’re not crazy, it isn’t you. It’s them. Really.

Well that day has come for me and the Singleton design pattern. In Steve Yegge’s Singleton Considered Stupid I found a friend to confirm my now near hatred for the so called singleton design pattern.

Singleton and I used to be close. When I first started seeing, and, I’ll admit it, using singleton I quickly began feeling a growing unease. I found myself callously using singleton to allocate an instance, and then never speaking to singleton or the instance again.

Then things went from bad to worse. Once I started testing singleton I noticed how self centered singleton was. How could someone insist that they always be “the only one”?

Finally I started cheating; using backhanded methods to use and discard whole series of singletons. I even always took care to keep each one ignorant of the other. I told myself it was just for “unit testing”, but I knew better.

Now I realize I can’t live like this. It’s over.

Now I will only be design patterns who don’t have to be the center of universe. No more cheating, no more lying.

I hope I never see another singleton again.

Late Night Lego Fishing

Ever had a moment when you suddenly realized that what you were doing was absolutely crazy?

It happened innocently enough, my son, during his bath, managed to drop a small lego piece down the bathtub drain and he was really disappointed (that happens often). For some reason after the water had drained, the piece was still visible under the grate (which usually traps slightly larger lego pieces, hair, and other valuables above the grate).

In any event, I started by bending a couple of my daughter’s bobby pins and using them as mini-chopsticks which which I could try and pull the lego out (the holes were too large for actual tweezers). After a few minutes I had to give up and get the kids dressed and off to bed.

Later that night I continued my quest to retrieve the small worthless piece of plastic. Half an hour later I decided the bobby pins weren’t going to work, and I was even having trouble imaging what angle the lego could possibly fit.

Suddenly I had a mental of a lego swirling as water rushes past it and then randomly finding the precise angle that it could pass through the grate. “If only I could do the reverse” I thought.

Then it struck me: the vacuum cleaner could do it reverse.

Five minutes later (at 12:30 AM I might add) I had the bathroom door shut and was turning on and off the vacuum cleaner. It was able to pull the lego piece back up against the grate and I was hopeful that with a few more tries would be enough to have the lego sucked into the empty vacuum cleaner where it could easily be retrieved.

Suddenly, my wife opens the bathroom door and isn’t happy.

“What are you doing?” she asks.

At that moment I was rendered speechless. It started off logically enough, but somehow I had become convinced that running the vacuum cleaner in the middle of the night with my wife sleeping in the next room to retrieve a lego was a good idea.

All I could was apologize and go to bed.

Not my smartest moment.

By the way, I did get the lego piece out the next day. The vacuum cleaner got it half way through the grate and a pair of needle nose pliers finished the job.