Organizing c# project helper or utility classes

spaghetticowboy picture spaghetticowboy · Jul 29, 2010 · Viewed 22.3k times · Source

What are some best practices for where you should have helper classes in a .NET project? Referring to classes separate from business layer stuff, but presentation and app stuff like appSetting config managers and other code that would sometimes be module specific or sometimes be used throughout the app.

Answer

John Saunders picture John Saunders · Jul 29, 2010

I always allow things like this to be pretty fluid. That said:

  1. I test "helper" classes the same as any other class. This makes them tend to not be static.
  2. I may start by creating these helpers as individual methods when needed. As I find they are needed in more than one class, I'll move them into their own class or a "Utilities" class in the same project.
  3. If I find they are needed in more than one project, then I move them higher up in the "hierarchy": from project to solution, from solution to subsystem, from subsystem to application, from application to library or framework, etc.