Naming for Classes

Feb 11, 2009 at 3:06 AM
Hi Kzu,

I tried leaving this as a comment on your blog, but that didn't work out so I figured I'd post it here. :)

I really think the term "container" is too overloaded and shouldn't be used in the context of IoC. What do you think about the idea of renaming "Container" and "ContainerBuilder" to something more descriptive, like "Resolver" and "TypeRegistry" or something?

So I'm thinking your code would look like:

    var reg = new TypeRegistry();
    reg.Register<IFoo>(r => new Foo());

    var res = reg.CreateResolver();
    var foo = res.Resolve<IFoo>();

"TypeRegistry" is the best name I could come up with offhand, but I don't particularly like it. "Resolver", however I think is a perfect name, given what the class actually does. "Container" seems like a silly name for something like that.

Cheers,
Matt Hamilton
Coordinator
Feb 26, 2009 at 5:54 PM
It's named Container 'cause it does more than just provide a registry of types to factories :)
i.e. reuse of instances across a hierarchy, or within a container, and lifetime management (IDisposable) within a container and hierarchy.

And the initializers could make the instances do much more (i.e. subscribing to a pub/sub system, etc.).

Hence, I think "Container" is fine :)