Brandon Werner

My favorite pattern

A while back, complaining about the horrible state of technical interviews, someone commented that he was asked what his favorite pattern was and he smuggly said pastel. Well, I would like to state for anyone that interviews me now or in the future for any job, that my absolute favorite pattern is the singleton.

My IntelliJ Singleton Pattern

It just looks erotic in UML.

NOTE: I generated this tonight to teach a friend about caching context lookups in his code. I generated it using IntelliJ’s excellent bare-bones SimpleUML plug-in. It doesn’t do anything else, but for quick looks at how you’re doing it’s great for small projects. It’s UMLish, certainly not UML2.

7 Responses to “My favorite pattern”

  1. Dan Hinojosa Says:

    I like the visitor pattern. Very sexy, rarely used.

  2. Laird Nelson Says:

    For some views in the other direction, see http://blogs.msdn.com/scottdensmore/archive/2004/05/25/140827.aspx and http://c2.com/cgi/wiki?SingletonsAreEvil.

    Cheers,
    Laird

  3. Brandon Werner Says:

    Yes..yes… the global variable issue. If it were used for anything other than a caching mechanism I would agree. However, looking at the alternatives for this application, I’ll accept the Faustian bargin. :-)

  4. Brandon Werner Says:

    Oh, I mean the Goethe’s Faust in the 1800s where he is saved at the end, not Marlowe’s Faustus in the 1600s play where he is damned. Although with singletons it could go either way…

  5. fletch Says:

    nooooooooooooooooooo… singleton is the worst pattern on the planet. look at dependency injection and pretend that singleton was like that vd you picked up in college and don’t ever tell anyone about any more.

  6. Brandon Werner Says:

    I think dependency injection was a little above and beyond what my friend was looking for at that moment ;-)

  7. Are we gonna bash Restlet next? at Brandon Werner Says:

    [...] This could mean more than just a replacement of course, but an eventual adoption and approval by the JCP. Just like Hibernate and Spring did to EJB persistence and Dependency Injection (killing my favorite asexual pattern, the Singleton), even a change in mind-set or “what is possible” could impact the next round of JCP submissions. In fact, This may already be happening as we speak. [...]

Leave a Reply