Do we need IoC containers?

8 באוקטובר 2009

2 תגובות

My blog has moved. You can view this post at the following address: http://blog.drorhelper.com/2009/10/do-we-need-ioc-containers.html

הוסף תגובה
facebook linkedin twitter email

כתיבת תגובה

האימייל לא יוצג באתר. שדות החובה מסומנים *

2 תגובות

  1. Rob Conery13 באוקטובר 2009 ב 8:57

    >>>I’m sorry to say I agree with Joel, IoC containers tend to cause less readable code and makes debugging container related problems a little hell. I do not think that like all development tools there are places that IoC containers can solve a real problem but developers should be aware of their cost.

    Interesting – many people share this opinion and 9 times out of 9 I find they haven't used IoC. You might have, but you offered your opinion and didn't really offer *why*.

    Now before you think I'm getting all uppity 🙂 – I'm not. I like conversation and I'm not trying to push IoC. It would be extremely helpful if you could tell me what IoC has to do with readability? Or the "little hell" of IoC problems? What are they? Why are they hell? Why can't IoC containers solve real problems?

    Here's why I ask: I spent a good amount of time going into detail on this – you've dismissed it in one sentence. Your URL says "microsoft" – you owe it to me and others to back it up :).

    Thanks for your time :).

    הגב
  2. Dror Helper13 באוקטובר 2009 ב 11:48

    You're right Rob – I do owe some explanations:

    1. I am not an employee of Microsoft, I only use their blogging platform to host my blog. What I write is strictly my opinion and thoughts. In fact I'm sure that Microsoft as an organisation do not have anything against IoC container (Unity).

    2. I failed to explain my meaning and give examples in this post – my bad. I wrote the article in a specific state of mind and tried to "get it off my chest" and in the process I forgot to explain what I'm talking about.

    So here goes:
    Just like you've said – IoC containers solve real actual day to day problems. I think that perhaps they are a it misused. Not every project needs IoC container and deciding to use IoC container should be weighted against what I think is its big drawback – code with IoC container is considered less readable. I witnessed developers reading a piece of code that uses IoC container and you can almost see the question marks.
    The other problem with IoC containers is that when they don't work because of some issue with the type you're using it's very hard to understand what is he problem.

    I'm not against IoC containers (in fact I'm in to process of integrating one in my project at work) and I know they are a valid solution just like dependency injection is a useful pattern, I just thought that in the specific question in StackOverflow perhaps the correct answer was – don't use them.

    I hope it helped clear things up (if I've missed something -ever- just let me know).

    Thank you for your feedback

    הגב