Which Typesafe Enum in C++ Are You Using?

I’m currently playing around with the Boost.Enum proposal from the Boost Vault (filename enum_rev4.6.zip). Although it was never officially submitted for inclusion into Boost, it’s useable as-is. (Documentation is lacking but is made up for by clear source code and good tests.) Boost.Enum lets you declare an enum like this: BOOST_ENUM_VALUES(Level, const char*, (Abort)(“unrecoverable problem”) … Read more

What’s the difference between the Dependency Injection and Service Locator patterns?

The difference may seem slight, but even with the ServiceLocator, the class is still responsible for creating its dependencies. It just uses the service locator to do it. With DI, the class is given its dependencies. It neither knows, nor cares where they come from. One important result of this is that the DI example … Read more

How will I know when to create an interface?

it solves this concrete problem: you have a, b, c, d of 4 different types. all over your code you have something like: a.Process(); b.Process(); c.Process(); d.Process(); why not have them implement IProcessable, and then do List<IProcessable> list; foreach(IProcessable p in list) p.Process(); this will scale much better when you add, say, 50 types of … Read more