3 ms·
He's actually managed to create a container by using the variable scope of the App class. That'll work fine for awhile, but it doesn't scale particularly well.
by nkohari 16y ago
He's actually managed to create a container by using the variable scope of the App class. That'll work fine for awhile, but it doesn't scale particularly well. You also lose lifecycle management (in his example, everything is a singleton) and lazy instantiation. Also, you lose the ability to isolate dependencies on external libraries to separate assemblies -- in this case, the main assembly needs to know everything about everything.
I'm biased (I wrote a DI framework for .NET), but I don't really understand what people think they're gaining by avoiding the use of a container. The complexity of dependency wiring increases geometrically with the size of your application, and I personally would like as much of that complexity hidden as possible.
- DanielRibeiro 16y agoIt is a good way to start. It is a bad way to end up. Dynamic languages can get away with not using IoC containers for large projects: http://onestepback.org/articles/depinj/index.html http://onestepback.org/articles/depinj/index.html On static languages, using a dynamic language DSL to configure the container will usually do wonders, while losing refactoring support (for instance, Spring plugin for Eclipse will be aware of all rename methods and rename classes, as long as you use the xml for configuration).