开发者

Are IoC containers about configuration files?

开发者 https://www.devze.com 2022-12-15 19:53 出处:网络
Recently I developed a performance tester console application, with no UI, with the help of a IoC containter (Castle-Windsor-Mi开发者_运维知识库crokernel). This library enabled me to let the user choo

Recently I developed a performance tester console application, with no UI, with the help of a IoC containter (Castle-Windsor-Mi开发者_运维知识库crokernel). This library enabled me to let the user choose which test(s) to run, simply by changing the configuration file.

Have I realized what IoC containers are about? I'm not sure. Even Joel said here on SO that IoC are difficult to understand.

From my example, what do you conclude? Am I using IoC container for exactly what they were designed for? Or I am just using one of its secondary features?


IoC containers are designed primarily to support DI (dependency injection). You seem to be just using a secondary feature, though it's hard to tell for sure from your description. Your use is valid, but not the primary one.

IoC containers are not about configuration files - in fact there are examples that don't use configuration files at all (e.g. LinFu).

Suggest you read up on dependency injection to find out what it's really all about.


Am I using IoC container for exactly what they were designed for?

It's one of the things they were designed for - so yes you are using them correctly in this case.


I strongly recommend you to read this article by Martin Fowler. It's a little lengthy but that's one of the best references.

IOC container is not a configuration framework. One of the ways to implement is using configuration files. Some containers even don't have config files to define the objects and inject them.

IOC is also referred to as Dependency Injection, which is a better name. What you did was actually one of the applications of it. You will be able to do more if you understand it thoroughly.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号