Choosing an IoC
Container
Boris Modylevsky August 24, 2016
About me
Boris
Modylevsky
Senior developer @Quali
Clean Code Alliance group organizer
www.borismod.net
twitter.com/bormod
github.com/borismod
What is Inversion of Control?
What is Inversion of Control?
Customer Flow Chart
SQL Server
Validate
Add
What is Inversion of Control?
Customer Flow Chart
Which
DAL?
SQL Oracle
Validate
Add
Is this
customer’s
work?
Good Code
A good code is that which takes care of his logic rather than
overloading himself with unconcerned logic.
Inversion of Control
Which
DAL?
SQL Oracle
Validate
Add
Customer
External
Entity
What is Inversion of Control?
• Decoupled system
• Cleaner code
• Easy to maintain and test
Inversion of Control benefits
The ability to supply (inject) an external
dependency into a software component.
Dependency Injection
Poor Man’s Dependency Injection
Dependency injection method by explicit
initialization of classes and providing their
dependencies
Demo
IoC Container
A software component which enables registration
and resolving classes and their dependencies
Explicit registration
Unity
Configuration File Registration
Unity
Constructor Injection
Attribute Injection
Method Injection
Lifetime Scope
• Transient
• Singleton
• Per Web/WCF request
• Custom
Singleton Registration
Unity
Auto Registration
The ability to register types automatically
based on rules provided
without specifying them manually.
Modules Registration
The ability to group types registration
by logical modules.
Interception
The ability to change or augment the usual
processing cycle.
.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
Popularity
Downloads in millions
0
0.5
1
1.5
2
2.5
3
3.5
4
Unity
Ninject
AutoFac
StructureMap
Downloads in millions
Demo
Performance
Transient resolve
Source: http://tinyurl.com/h7qntep by
Nathanael Mann
Demo
Compare
Popularity
Maturity
Readability
Environment
Maintenance
Integrations
Performance
Features
Performance Comparison
Container Performance
AutoFac Average
DryIoc Fast
Dynamo Fast
LinFu Slow
Ninject Slow
SimpleInjector Fast
StructureMap Average
Unity Average
Windsor Average
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
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
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
How to choose?
Thanks!
Questions?

Choosing an IoC container

Editor's Notes

  • #15 Demo only Poor Man’s DI
  • #17 Unity 4 Ninject 3.4 AutoFac 2.5 StructureMap 1.2 Windsor 1.1
  • #26 This is the last slide on IoC container features
  • #28 Unity 4 Ninject 3.4 AutoFac 2.5 StructureMap 1.2 Windsor 1.1
  • #29 Demo until Ninject including
  • #31 Demo with Autofac and ResharperTnT