none
what is IOC

    Question

  • please discuss what is IOC and what is the use of IOC. why one should use IOC i mean what is the advantage of IOC in c# program and what kind of situation IOC is required. please explain with sample code in c#. please do not give me any url rather discuss over here.

    thanks

    Saturday, April 09, 2011 4:43 PM

Answers

  • That is an abstract principle, not a C# feature. If you need help in software design, visit a software design forum like the ones under the Architecture category.

    If you are talking about a specific implementation of the principle, you need to find the forum for the specific implementation. For example, the forum for Unity is at http://unity.codeplex.com/discussions.



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    • Marked as answer by Aspen VJ Monday, April 18, 2011 8:05 AM
    Saturday, April 09, 2011 7:29 PM
  • IOC is also called Dependency Injection (or DI), a simple google search yields a lot of good articles on this subject.

    What do you want to know, which isn't covered there?

    http://www.google.nl/search?hl=nl&q=why+use+dependency+injection

    http://www.google.nl/search?hl=nl&q=why+use+inversion+of+control+pattern

    http://msdn.microsoft.com/en-us/library/aa973811.aspx

    There are a lot of IOC frameworks available, but the main thing about IOC is about the principle of giving a class its dependencies, instead of letting a class create its own dependencies.

    So instead of letting your Business class create its own DataAccess class to access the database, it is supplied with a DataAccess class by some 3rd party (could be your calling code, could be a DI container). This way you are in control of how the Business class accesses its data. This makes it much easier to change your DataAccess class, or to test the Business class. Which are the two main reasons for using IOC/DI.

     

    • Marked as answer by Aspen VJ Monday, April 18, 2011 8:05 AM
    Sunday, April 10, 2011 6:13 PM
  • You can follow this link:

    http://msdn.microsoft.com/en-us/library/ff921087.aspx


    Please Mark it as answer, if it helps solve your problem.
    • Marked as answer by Aspen VJ Monday, April 18, 2011 8:06 AM
    Monday, April 11, 2011 7:53 AM

All replies

  • International Olympic Committee (?)

    Or possibly Inversion Of Control. If you want a discussion look at design patterns since this is not something specific to C#.

     


    Regards David R ---------------------------------------------------------------
    Every program eventually becomes rococo, and then rubble. - Alan Perlis
    The only valid measurement of code quality: WTFs/minute.
    Saturday, April 09, 2011 5:28 PM
  • i am asking about Inversion Of Control IOC. if u know about the Inversion Of Control then please discuss what is the use of Inversion Of Control . why one should use Inversion Of Control i mean what is the advantage of Inversion Of Control  in c# program and what kind of situation Inversion Of Control is required. please explain with sample code in c#. please do not give me any url rather discuss over here.
    Saturday, April 09, 2011 5:33 PM
  • That is an abstract principle, not a C# feature. If you need help in software design, visit a software design forum like the ones under the Architecture category.

    If you are talking about a specific implementation of the principle, you need to find the forum for the specific implementation. For example, the forum for Unity is at http://unity.codeplex.com/discussions.



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    • Marked as answer by Aspen VJ Monday, April 18, 2011 8:05 AM
    Saturday, April 09, 2011 7:29 PM
  • IOC is also called Dependency Injection (or DI), a simple google search yields a lot of good articles on this subject.

    What do you want to know, which isn't covered there?

    http://www.google.nl/search?hl=nl&q=why+use+dependency+injection

    http://www.google.nl/search?hl=nl&q=why+use+inversion+of+control+pattern

    http://msdn.microsoft.com/en-us/library/aa973811.aspx

    There are a lot of IOC frameworks available, but the main thing about IOC is about the principle of giving a class its dependencies, instead of letting a class create its own dependencies.

    So instead of letting your Business class create its own DataAccess class to access the database, it is supplied with a DataAccess class by some 3rd party (could be your calling code, could be a DI container). This way you are in control of how the Business class accesses its data. This makes it much easier to change your DataAccess class, or to test the Business class. Which are the two main reasons for using IOC/DI.

     

    • Marked as answer by Aspen VJ Monday, April 18, 2011 8:05 AM
    Sunday, April 10, 2011 6:13 PM
  • You can follow this link:

    http://msdn.microsoft.com/en-us/library/ff921087.aspx


    Please Mark it as answer, if it helps solve your problem.
    • Marked as answer by Aspen VJ Monday, April 18, 2011 8:06 AM
    Monday, April 11, 2011 7:53 AM