The Artima Developer Community
Sponsored Link

Agile Buzz Forum
mocking a singleton

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Kevin Rutherford

Posts: 171
Nickname: spinach
Registered: Apr, 2006

Kevin Rutherford is an independent agile software development coach based in the UK
mocking a singleton Posted: May 1, 2006 8:13 AM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by Kevin Rutherford.
Original Post: mocking a singleton
Feed Title: silk and spinach
Feed URL: http://silkandspinach.net/blog/index.xml
Feed Description: kevin rutherford on agile software development and life in macclesfield
Latest Agile Buzz Posts
Latest Agile Buzz Posts by Kevin Rutherford
Latest Posts From silk and spinach

Advertisement

Jeffrey Frederick (link via Robert) highlights a splendid piece of humour by Mike Hill on the Yahoo testdrivendevelopment list. In discussing the use of mock objects to test Singletons, Mike said:

"Mocking a singleton is relatively easy.

"To begin with, singleton's are all alone in the world; don't be afraid to point this out. Also, most singletons are created, get this, not even in a factory, but merely in a factory method. Finally there is the point that they are little more than dressed-up globals, and IME experience cause more heartache than they're worth. You can point to the many nasty screeds about singletons there are out on the net. All in all, mocking it shouldn't be too hard. A word: if your singleton has unusually large body parts, stoop to insulting that. Sometimes, to be kind, you have to be cruel."

The humour arises mostly from the pun on 'mock', of course, but also partly from deconstruction of the term 'singleton'. I find it fascinating just how quickly and completely a metaphor such as this can come to be adopted as primary language. To the extent that we get a small shock when someone reminds us where the term originally came from.

Many of the GoF design patterns have names that are metaphors (Bridge, Factory, Singleton, etc) and I think that's an important factor in their success. A few lines of code in some software aren't really a Factory; but the name evokes so many connections with the real world counterpart that we can quickly understand what those lines of code do (or were intended to do). We've stolen a word form another domain, so that the baggage it brings along will help us understand something new and more abstract.

Our industry is riddled with metaphors: windows, mouse, boot-strap, object, broker, layers. They help us bring our real-world, tangible experiences to bear on complex, abstract subjects. It would be hard to imagine life without them.

Look out for my conference workshops on the power and use of metaphors later this year. In the meantime, what has been the most useful metaphor you've encountered in software development? Which metaphors are the most surprising? Which are the most deeply ingrained?

Read: mocking a singleton

Topic: When the abstractions need to be bailed out Previous Topic   Next Topic Topic: If he's invited, it's ok

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use