Derik Whittaker

Syndication

News


You know you buy into Testing and Testabilty when you wrap a singleton simply to create an abstraction…

I am a little bored so I thought I would write a nice fluent interface around the Performance Counter crap that is part of .net.  I know, I know the world does not really need another Fluent Interface around something, but I am bored and this is keeping be busy while waiting for my flight.

Anyway, about 30 min into the coding session (going a bit slow as I am trying to use CodeRush/Refactor Pro in place of ReSharper) I needed to use the PerformanceCounterCategory class.  The problem is this.  Since this is a singleton isolating this during my tests is too painful, and because it is a singleton I cannot create an inheritance hierarchy to allow me to isolate it better.  So, what did I do? 

I created a wrapper around the singleton.  By having this wrapper (and accompanying interface) I will be able to better isolate my tests and not actually create a shit load of categories and counters all the time.

Wrap Strategy Refactoring === FOR THE WIN

Singletons == FOR THE LOSS

Till next time,


Posted 05-15-2009 5:27 PM by Derik Whittaker
Filed under: ,

[Advertisement]

Comments

Sandor Davidhazi wrote re: You know you buy into Testing and Testabilty when you wrap a singleton simply to create an abstraction…
on 05-17-2009 6:35 PM

Do you find Resharper or Refactor Pro/CodeRush better?

Derik Whittaker wrote re: You know you buy into Testing and Testabilty when you wrap a singleton simply to create an abstraction…
on 05-17-2009 6:53 PM

@Sandor,

I am still learning CR so no comment yet

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)