Just out of whimsy, here’s my list of classes or interfaces that seem to show up in every project I work on.
- Bootstrapper – sets up StructureMap and whatever UI machinery. I formalized this in StructureMap 2.5 for diagnostic purposes.
- Debugging – Just a test fixture marked as explicit for playing with little bits of code and troubleshooting
- ObjectMother and/or DataMother (Test Data Builder ala Nat Pryce)
- TestUtility – Usually just a quickie way to run Fit/StoryTeller tests inside of NUnit tests
- ICommand – Execute() and usually something else
- A console app called DatabaseGenerator to setup the development and testing databases. Wraps the NHibernate hbm2ddl tool for us.
- A console app called CodeGen to kick off whatever code generation we’re using. We codegen DTO’s and Fit Fixture classes.
- If it’s a desktop application, I’ll have an ApplicationController and ApplicationShell
- SpecificationExtensions – This is relatively new. I love the SpecUnit stuff that Bellware did with extension methods for RSpec like unit test assertions. We add our own extensions at will.
- XmlExtensions – Extension methods for Xml manipulation. Just a little bit of effort makes Xml consumption so much easier
- IRepository. We dumped IRepository<T> with Save(T) methods in favor of IRepository with Save<T>(T) and use Linq for NHibernate to express queries to avoid having to write one off repositories for each aggregate root. It’s too early to say if it’s a better approach, but I’m hopeful. Our current one looks like:
public interface IRepository
{
T Find<T>(long id) where T : Entity;
void Delete<T>(T target);
T[] Query<T>(Expression<System.Func<T, bool>> where);
T FindBy<T, U>(Expression<System.Func<T, U>> expression, U search) where T : class;
T FindBy<T>(Expression<System.Func<T, bool>> where);
void Save<T>(T target);
}
What’s yours? Or is this just a sign of being in a rut?