Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Choosing an IoC container

3,615 views

Published on

What is Inversion of Control and why we should care? What are IoC Containers and when we can use them? What are the most popular IoC container in the .NET eco system? How to choose the IoC container that best fits your needs?

We'll try to answer on the above questions and we'll see some real examples of IoC containers usages.

Published in: Software
  • Hello there! Get Your Professional Job-Winning Resume Here! http://bit.ly/topresum
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Choosing an IoC container

  1. 1. Choosing an IoC Container Boris Modylevsky August 24, 2016
  2. 2. About me Boris Modylevsky Senior developer @Quali Clean Code Alliance group organizer www.borismod.net twitter.com/bormod github.com/borismod
  3. 3. What is Inversion of Control?
  4. 4. What is Inversion of Control?
  5. 5. Customer Flow Chart SQL Server Validate Add
  6. 6. What is Inversion of Control?
  7. 7. Customer Flow Chart Which DAL? SQL Oracle Validate Add Is this customer’s work?
  8. 8. Good Code A good code is that which takes care of his logic rather than overloading himself with unconcerned logic.
  9. 9. Inversion of Control Which DAL? SQL Oracle Validate Add Customer External Entity
  10. 10. What is Inversion of Control?
  11. 11. • Decoupled system • Cleaner code • Easy to maintain and test Inversion of Control benefits
  12. 12. The ability to supply (inject) an external dependency into a software component. Dependency Injection
  13. 13. Poor Man’s Dependency Injection Dependency injection method by explicit initialization of classes and providing their dependencies
  14. 14. Demo
  15. 15. IoC Container A software component which enables registration and resolving classes and their dependencies
  16. 16. Explicit registration Unity
  17. 17. Configuration File Registration Unity
  18. 18. Constructor Injection
  19. 19. Attribute Injection
  20. 20. Method Injection
  21. 21. Lifetime Scope • Transient • Singleton • Per Web/WCF request • Custom
  22. 22. Singleton Registration Unity
  23. 23. Auto Registration The ability to register types automatically based on rules provided without specifying them manually.
  24. 24. Modules Registration The ability to group types registration by logical modules.
  25. 25. Interception The ability to change or augment the usual processing cycle.
  26. 26. .NET IoC Containers AutoFac fFastInje ctor Hiro Maestro Munq Speedioc TinyIo c Caliburn. Micro Funq IfInjecto r MEF Ninject Spring.N ET Unity Catel Grace LightCo re MEF2 Petite Stiletto Wind sor DryIoc Griffin LightInj ect MicroSli ver QuickInjec t Structure Map No Dynamo HaveBox LinFu Mugen SimpleInje ctor StyleMVV M Unity
  27. 27. Popularity Downloads in millions 0 0.5 1 1.5 2 2.5 3 3.5 4 Unity Ninject AutoFac StructureMap Downloads in millions
  28. 28. Demo
  29. 29. Performance Transient resolve Source: http://tinyurl.com/h7qntep by Nathanael Mann
  30. 30. Demo
  31. 31. Compare Popularity Maturity Readability Environment Maintenance Integrations Performance Features
  32. 32. Performance Comparison Container Performance AutoFac Average DryIoc Fast Dynamo Fast LinFu Slow Ninject Slow SimpleInjector Fast StructureMap Average Unity Average Windsor Average
  33. 33. Registration Comparison Container Code XML Auto AutoFac Yes Yes Yes DryIoc Yes Dynamo Yes Yes LinFu Yes Ninject Yes Yes Yes SimpleInjector Yes Yes StructureMap Yes Yes Yes Unity Yes Yes Yes Windsor Yes Yes Yes
  34. 34. Features Comparison Container Autowiring Custom lifetimes Interception AutoFac Yes Yes DryIoc Yes Yes Dynamo Yes Yes LinFu Yes Yes Ninject Yes Yes SimpleInjector Yes Yes Yes StructureMap Yes Yes Yes Unity Yes Yes Yes Windsor Yes Yes Yes
  35. 35. Environments Comparison Container .NET SL WP7 WP8 WinRT AutoFac Yes Yes Yes Yes Yes DryIoc Yes Dynamo Yes LinFu Yes Ninject Yes Yes Yes Yes SimpleInjector Yes Yes Yes Yes StructureMap Yes Yes Yes Unity Yes Yes Yes Yes Windsor Yes Yes
  36. 36. How to choose?
  37. 37. Thanks! Questions?

×