Utility classes for timing, tracing and configuration

In a series of four articles (including this) I will discuss three utility classes that I frequently use when I as a consultant write code for my customers. These classes have been in development for a long time, timerHelper since 2001 and the other for a couple of years, and most times I have used them in a project they have been extended and bugs have been fixed. The classes I will discuss are:

  • timerHelper: High-precision timer class. Used to measure duration of millisecond operations.
  • configurationHelper: Easy to use configuration store, can be shared among multiple applications.
  • traceHelper: Support for multi-level tracing which can write to both OutputDebugString and to file.

The functionality of two of these classes, configurationHelper and traceHelper, are at least partially available in the Enterprise Library for .NET Framework 2.0 (EL). Why have I, as a Microsoft employee, choosen not to use EL? The reason is simple, EL is big and complex while my classes are extremely light-weight and easy to use. If the customer I work with already have chosen to use a utility framework (either EL or something else) I will have no problem using that (but hasn’t happened yet :-).

 

I admit that using these classes has an element of "not invented here", when someone suggests something else I make an argument for my classes. But if I can get other people to accept the simplicity of my classes then I guess they must have something that is worth having.

 

I intend to include source code for all three of these classes. And while all have been used in production environments for a while I make no guarantees of functionality (proper disclaimer will be included!).

 

The first class discussed will be timerHelper. Next up is the configurationHelper and last will be the traceHelper. The reason for this order is that timerHelper is simplest so it's easiest to start with, and as traceHelper uses configurationHelper it cannot be discussed before that class.