Upload
boris-modylevsky
View
376
Download
0
Embed Size (px)
Citation preview
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
CustomerExternal
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 registrationUnity
Configuration File RegistrationUnity
Constructor Injection
Attribute Injection
Method Injection
Lifetime Scope
• Transient• Singleton• Per Web/WCF request• Custom
Singleton RegistrationUnity
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 fFastInjector Hiro Maestr
o Munq Speedioc
TinyIoc
Caliburn.Micro Funq IfInject
or MEF Ninject Spring.NET
Unity
Catel Grace LightCore MEF2 Petite Stiletto Win
dsor
DryIoc Griffin LightInject
MicroSliver
QuickInject
StructureMap No
Dynamo HaveBox LinFu Mugen SimpleInj
ectorStyleMVVM
Unity
PopularityDownloads in millions
UnityNinject
AutoFacStructureMap
0
0.5
1
1.5
2
2.5
3
3.5
4
Downloads in millions
Demo
PerformanceTransient 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 AutoAutoFac Yes Yes YesDryIoc Yes Dynamo Yes YesLinFu Yes Ninject Yes Yes YesSimpleInjector Yes Yes
StructureMap Yes Yes YesUnity Yes Yes YesWindsor Yes Yes Yes
Features Comparison
Container Autowiring Custom lifetimes Interception
AutoFac Yes YesDryIoc Yes Yes Dynamo Yes Yes LinFu Yes YesNinject Yes YesSimpleInjector Yes Yes Yes
StructureMap Yes Yes Yes
Unity Yes Yes YesWindsor 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?