Dennis Doomen | @ddoomen | Aviva Solutions | The Continuous Improver
Strengths and weaknesses of dependency injection
Strengths and weaknesses of dependency injection
Order Processing
IOrderRepository
Nhibernate
OrderRepository
Storage
RavenDB
OrderRepository
Storage Storage
In-memory
Repository
Bookkeeping
Diagnostics
Decorator
Diagnostics
Decorator
Strategy Selection
Allow Test-time
dependencies
Inject
dependencies
from different
modules
Control lifecycle
(e.g. per http request,
singleton, etc)
Inject Cross-cutting
Concerns
Promote depending
on abstractions
Strengths and weaknesses of dependency injection
Strengths and weaknesses of dependency injection
Strengths and weaknesses of dependency injection
Strengths and weaknesses of dependency injection
Strengths and weaknesses of dependency injection
Strengths and weaknesses of dependency injection
Strengths and weaknesses of dependency injection
Strengths and weaknesses of dependency injection
Strengths and weaknesses of dependency injection
Order Processing
IStoreOrders<T>
+ CreateQuery<T>();
+ Add<T>();
+ Delete<T>();
NHibernate
Repository
Order Processing
IStoreOrders
+ GetIncompletedOrders(minValue);
+ StoreOrder();
+ CompleteOrder();
OrderRepository
VS
Strengths and weaknesses of dependency injection
• Don’t use the Service Locator pattern
• Use container only at the root…
• …so don’t use the container as a dependency
• Constructor injection only
• Pass local dependencies to methods
• Avoid container-specific dependencies
• Use delegates for factories, indexes, etc.
• Include registrations in at least one test
• Use types explicitly in registrations
• Let the container handle the life cycle
• Access date & time through delegate
• Avoid configuration-based setup (e.g. XML).
Strengths and weaknesses of dependency injection
System
Package
Package
Package
PackagePackage
Package
Maybe
Probably not
Probably yes
TinyIoc
Autofac
Strengths and weaknesses of dependency injection

More Related Content

PPTX
How To Practice TDD Without Shooting Yourself In The Foot
PDF
Scalable Event Processing with WSO2CEP @ WSO2Con2015eu
PDF
Test box bdd
PDF
Intro to Time Series
PDF
Monitoring, the Prometheus Way - Julius Voltz, Prometheus
PPTX
Bringing DevOps to the Database
PDF
What's new in JBoss ON 3.2
PPTX
Internals of Steroids Framework
How To Practice TDD Without Shooting Yourself In The Foot
Scalable Event Processing with WSO2CEP @ WSO2Con2015eu
Test box bdd
Intro to Time Series
Monitoring, the Prometheus Way - Julius Voltz, Prometheus
Bringing DevOps to the Database
What's new in JBoss ON 3.2
Internals of Steroids Framework

Similar to Strengths and weaknesses of dependency injection (20)

PPTX
Architecting for Microservices Part 2
PPTX
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)
PPTX
Migration to ClickHouse. Practical guide, by Alexander Zaitsev
PDF
Scaling MySQL Strategies for Developers
PPTX
PPTX
Monitoring Docker containers - Docker NYC Feb 2015
PPTX
.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven Design
KEY
Seedhack MongoDB 2011
PPT
LINQ-Introduction.ppt
PPT
Unit Testing DFC
PDF
hbaseconasia2019 Phoenix Improvements and Practices on Cloud HBase at Alibaba
PPTX
[NetPonto] NoSQL em Windows Azure Table Storage
PDF
CBDW2014 - Behavior Driven Development with TestBox
PPTX
Dealing with and learning from the sandbox
PPTX
Test-Driven Development
PDF
Rails Security
PDF
Five Enterprise Development Best Practices That EVERY Salesforce Org Can Use
PPTX
Utilizing the OpenNTF Domino API
PDF
Functional Domain Modeling - The ZIO 2 Way
PPTX
Microsoft Azure - Basic concepts presentation
Architecting for Microservices Part 2
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)
Migration to ClickHouse. Practical guide, by Alexander Zaitsev
Scaling MySQL Strategies for Developers
Monitoring Docker containers - Docker NYC Feb 2015
.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven Design
Seedhack MongoDB 2011
LINQ-Introduction.ppt
Unit Testing DFC
hbaseconasia2019 Phoenix Improvements and Practices on Cloud HBase at Alibaba
[NetPonto] NoSQL em Windows Azure Table Storage
CBDW2014 - Behavior Driven Development with TestBox
Dealing with and learning from the sandbox
Test-Driven Development
Rails Security
Five Enterprise Development Best Practices That EVERY Salesforce Org Can Use
Utilizing the OpenNTF Domino API
Functional Domain Modeling - The ZIO 2 Way
Microsoft Azure - Basic concepts presentation
Ad

More from Dennis Doomen (20)

PDF
15 Years of Insights from a TDD Practitioner (NDC Oslo)
PPTX
Using Boundary-Driven Development to beat code complexity
PPTX
Getting a grip on your code dependencies (2023-10)
PPTX
Tools and practices to help you deal with legacy code
PPTX
What you can learn from an open-source project with 250 million downloads
PPTX
Getting a grip on your code dependencies
PPTX
My Laws of Test Driven Development (2023)
PPTX
Design patterns for Event Sourcing in .NET
PPTX
Automate Infrastructure with Pulumi and C#
PPTX
What is the right unit in unit testing (UpdateConf 2022)
PPTX
Slow Event Sourcing (re)projections - Just make them faster!
PPTX
50 things software teams should not do.pptx
PPTX
What is the right "unit" in unit testing and why it is not a class?
PPTX
A lab around the principles and practices for writing maintainable code
PPTX
How to Practice TDD Without Shooting Yourself in the Foot
PPTX
Decomposing the Monolith using modern-day .NET and a touch of microservices
PPTX
Event Sourcing from the Trenches (DDD Europe 2020)
PPTX
Practical introduction to DDD, CQRS and Event Sourcing
PPTX
How to practice TDD without shooting yourself in the foot
PPTX
Decomposing the Monolith (Riga Dev Days 2019)
15 Years of Insights from a TDD Practitioner (NDC Oslo)
Using Boundary-Driven Development to beat code complexity
Getting a grip on your code dependencies (2023-10)
Tools and practices to help you deal with legacy code
What you can learn from an open-source project with 250 million downloads
Getting a grip on your code dependencies
My Laws of Test Driven Development (2023)
Design patterns for Event Sourcing in .NET
Automate Infrastructure with Pulumi and C#
What is the right unit in unit testing (UpdateConf 2022)
Slow Event Sourcing (re)projections - Just make them faster!
50 things software teams should not do.pptx
What is the right "unit" in unit testing and why it is not a class?
A lab around the principles and practices for writing maintainable code
How to Practice TDD Without Shooting Yourself in the Foot
Decomposing the Monolith using modern-day .NET and a touch of microservices
Event Sourcing from the Trenches (DDD Europe 2020)
Practical introduction to DDD, CQRS and Event Sourcing
How to practice TDD without shooting yourself in the foot
Decomposing the Monolith (Riga Dev Days 2019)
Ad

Recently uploaded (20)

PDF
Altius execution marketplace concept.pdf
PDF
A hybrid framework for wild animal classification using fine-tuned DenseNet12...
PDF
Introduction to MCP and A2A Protocols: Enabling Agent Communication
PDF
Co-training pseudo-labeling for text classification with support vector machi...
PDF
substrate PowerPoint Presentation basic one
PDF
Build Real-Time ML Apps with Python, Feast & NoSQL
PDF
“The Future of Visual AI: Efficient Multimodal Intelligence,” a Keynote Prese...
PPTX
AI-driven Assurance Across Your End-to-end Network With ThousandEyes
PDF
Transform-Your-Streaming-Platform-with-AI-Driven-Quality-Engineering.pdf
PDF
CXOs-Are-you-still-doing-manual-DevOps-in-the-age-of-AI.pdf
PDF
Examining Bias in AI Generated News Content.pdf
PDF
CEH Module 2 Footprinting CEH V13, concepts
PPTX
SGT Report The Beast Plan and Cyberphysical Systems of Control
PDF
A symptom-driven medical diagnosis support model based on machine learning te...
PDF
LMS bot: enhanced learning management systems for improved student learning e...
PDF
Human Computer Interaction Miterm Lesson
PDF
5-Ways-AI-is-Revolutionizing-Telecom-Quality-Engineering.pdf
PDF
Electrocardiogram sequences data analytics and classification using unsupervi...
PDF
Rapid Prototyping: A lecture on prototyping techniques for interface design
PDF
Dell Pro Micro: Speed customer interactions, patient processing, and learning...
Altius execution marketplace concept.pdf
A hybrid framework for wild animal classification using fine-tuned DenseNet12...
Introduction to MCP and A2A Protocols: Enabling Agent Communication
Co-training pseudo-labeling for text classification with support vector machi...
substrate PowerPoint Presentation basic one
Build Real-Time ML Apps with Python, Feast & NoSQL
“The Future of Visual AI: Efficient Multimodal Intelligence,” a Keynote Prese...
AI-driven Assurance Across Your End-to-end Network With ThousandEyes
Transform-Your-Streaming-Platform-with-AI-Driven-Quality-Engineering.pdf
CXOs-Are-you-still-doing-manual-DevOps-in-the-age-of-AI.pdf
Examining Bias in AI Generated News Content.pdf
CEH Module 2 Footprinting CEH V13, concepts
SGT Report The Beast Plan and Cyberphysical Systems of Control
A symptom-driven medical diagnosis support model based on machine learning te...
LMS bot: enhanced learning management systems for improved student learning e...
Human Computer Interaction Miterm Lesson
5-Ways-AI-is-Revolutionizing-Telecom-Quality-Engineering.pdf
Electrocardiogram sequences data analytics and classification using unsupervi...
Rapid Prototyping: A lecture on prototyping techniques for interface design
Dell Pro Micro: Speed customer interactions, patient processing, and learning...

Strengths and weaknesses of dependency injection