SlideShare a Scribd company logo
1 of 44
the zen of IoC


                 diogo.lucas@gmail.com
back to basics (1968)
coupling: bad
cohesion: good
now, things evolve…
encapsulation       interop
SOA mocking
 interfaces      TDD
OOD     Multi-layer
      inheritance
                    patterns
SOLID frameworks
refactoring
         FAIR
             OOP        polymorphism
so, nowadays...
cohesion: good
coupling: bad
a subtle case of coupling
coupling here


var repo = new UserRepository();
var users = repo.GetAll();
I can’t test this thing!


            What? This test hits the database?!?



       This refactoring will take ages…




   constructor coupling blues
How do I link this view and controller?


  But this new class implements this interface!
enter IoC
IoC is a concept
             (what)
DI is a pattern
            (how)
lifetime dependency

injection through
                    concurrency safe
   construction
                    simplest approach
simpler construction

injection through
                    flexible injection
    properties
                    concurrency risks
flexible injection

injection through   concurrency risks

    interfaces      equivalent to props

                    harder setup
the evil twin
lifecycle control

                  smaller contracts
service locator
                  concurrency risks

                  testing is a b*
Castle Windsor

                     Unity
tools of the trade
                     NInject

                     SimpleInjector
consequences
dude, where’s my code?
ramping + tooling
smell: lots of dependencies
man, your code already sucks
risk: interfaces abound
grain of salt + refactoring
risk: locators everywhere
KISS
natural pluggable design
overdriven Liskov
easy mocking
great enabler for tdd
issue: DDD & IoC mismatch
no easy way out
interception easily doable
added flexibility
good-bye to singletons
let the container handle this
tks.
True insight does not issue from specialized knowledge, from
                        membership in coteries, from doctrines or dogmas. It comes
                        from the preconscious intuitions of one's whole being, from one's
                        own code.

   Everything exists in relation to other things.

                                   Being a spectator while one is also a participant spoils
                                   one's performance.


                                  zen quotes
Security and changelessness are fabricated by the
ego-dominated mind and do not exit in nature. To
accept insecurity and commit oneself to the
unknown creates a relaxing faith in the universe.
                                       In emptiness, forms are born. When one becomes
                                       empty of the assumptions,
                                       inferences, and judgments he has acquired over the
                                       years, he comes close to his
                                       original nature and is capable of conceiving original ideas
                                       and reacting freshly.
fowler on IoC:
     http://martinfowler.com/articles/injection.html
     http://martinfowler.com/bliki/InversionOfControl.html
interception on SI:
     http://simpleinjector.codeplex.com/wikipage?title=InterceptionExtensions
IoC x anemic DM
     http://programmers.stackexchange.com/questions/72768/does-inversion-of-
     control-promote-anemic-domain-model
image source:
     http://photopin.com
the tao of IoC

                 diogo.lucas@gmail.com

More Related Content

Viewers also liked

157642973 skema-12-1-2-bi-trial-sbp-pmr-2013
157642973 skema-12-1-2-bi-trial-sbp-pmr-2013157642973 skema-12-1-2-bi-trial-sbp-pmr-2013
157642973 skema-12-1-2-bi-trial-sbp-pmr-2013Sani Untong
 
157231322 sbp-bi-trial-pmr-kertas-2-2013
157231322 sbp-bi-trial-pmr-kertas-2-2013 157231322 sbp-bi-trial-pmr-kertas-2-2013
157231322 sbp-bi-trial-pmr-kertas-2-2013 Sani Untong
 
Agile @ UniRitter
Agile @ UniRitterAgile @ UniRitter
Agile @ UniRitterDiogo Lucas
 
Alytus tiltas tarp imperijų
Alytus   tiltas tarp imperijųAlytus   tiltas tarp imperijų
Alytus tiltas tarp imperijųVanago
 
Estratégias e desafios na implantação de Lean no setor público e privado
Estratégias e desafios na implantação de Lean no setor público e privadoEstratégias e desafios na implantação de Lean no setor público e privado
Estratégias e desafios na implantação de Lean no setor público e privadoDiogo Lucas
 
Pristatymas
PristatymasPristatymas
PristatymasVanago
 

Viewers also liked (10)

Visual thinking
Visual thinkingVisual thinking
Visual thinking
 
157642973 skema-12-1-2-bi-trial-sbp-pmr-2013
157642973 skema-12-1-2-bi-trial-sbp-pmr-2013157642973 skema-12-1-2-bi-trial-sbp-pmr-2013
157642973 skema-12-1-2-bi-trial-sbp-pmr-2013
 
157231322 sbp-bi-trial-pmr-kertas-2-2013
157231322 sbp-bi-trial-pmr-kertas-2-2013 157231322 sbp-bi-trial-pmr-kertas-2-2013
157231322 sbp-bi-trial-pmr-kertas-2-2013
 
Friendship
FriendshipFriendship
Friendship
 
Agile @ UniRitter
Agile @ UniRitterAgile @ UniRitter
Agile @ UniRitter
 
Alytus tiltas tarp imperijų
Alytus   tiltas tarp imperijųAlytus   tiltas tarp imperijų
Alytus tiltas tarp imperijų
 
Friendship
FriendshipFriendship
Friendship
 
Estratégias e desafios na implantação de Lean no setor público e privado
Estratégias e desafios na implantação de Lean no setor público e privadoEstratégias e desafios na implantação de Lean no setor público e privado
Estratégias e desafios na implantação de Lean no setor público e privado
 
Pristatymas
PristatymasPristatymas
Pristatymas
 
Reflective Writing
Reflective WritingReflective Writing
Reflective Writing
 

Similar to The Zen of IoC

Dependency Inversion in large-scale TypeScript applications with InversifyJS
Dependency Inversion in large-scale TypeScript applications with InversifyJSDependency Inversion in large-scale TypeScript applications with InversifyJS
Dependency Inversion in large-scale TypeScript applications with InversifyJSRemo Jansen
 
DevSecCon London 2017: The flaws in hordes, the security in crowds by Mike Shema
DevSecCon London 2017: The flaws in hordes, the security in crowds by Mike ShemaDevSecCon London 2017: The flaws in hordes, the security in crowds by Mike Shema
DevSecCon London 2017: The flaws in hordes, the security in crowds by Mike ShemaDevSecCon
 
Oleksandr Valetskyy - Become a .NET dependency injection ninja with Ninject
Oleksandr Valetskyy - Become a .NET dependency injection ninja with NinjectOleksandr Valetskyy - Become a .NET dependency injection ninja with Ninject
Oleksandr Valetskyy - Become a .NET dependency injection ninja with NinjectOleksandr Valetskyy
 
10 Reasons Your Software Sucks - Election 2012 Edition
10 Reasons Your Software Sucks - Election 2012 Edition10 Reasons Your Software Sucks - Election 2012 Edition
10 Reasons Your Software Sucks - Election 2012 EditionCaleb Jenkins
 
Variability, Bugs, and Cognition
Variability, Bugs, and CognitionVariability, Bugs, and Cognition
Variability, Bugs, and CognitionAndrzej Wasowski
 
Dependency Injection Lightning Talk
Dependency Injection Lightning TalkDependency Injection Lightning Talk
Dependency Injection Lightning TalkJon Bachelor
 
10 practices that every developer needs to start right now
10 practices that every developer needs to start right now10 practices that every developer needs to start right now
10 practices that every developer needs to start right nowCaleb Jenkins
 
Dependency Inversion Principle
Dependency Inversion PrincipleDependency Inversion Principle
Dependency Inversion PrincipleShahriar Hyder
 
Developer Job in Practice
Developer Job in PracticeDeveloper Job in Practice
Developer Job in Practiceintive
 
KevlinHenney_PuttingThereIntoArchitecture
KevlinHenney_PuttingThereIntoArchitectureKevlinHenney_PuttingThereIntoArchitecture
KevlinHenney_PuttingThereIntoArchitectureKostas Mavridis
 
Continuous integration 101
Continuous integration 101Continuous integration 101
Continuous integration 101Manuel Spezzani
 
Cyber security innovation imho
Cyber security innovation imhoCyber security innovation imho
Cyber security innovation imhoW Fred Seigneur
 
Togetherlearn Learntrends
Togetherlearn LearntrendsTogetherlearn Learntrends
Togetherlearn LearntrendsLearnTrends
 
Patterns for the People
Patterns for the PeoplePatterns for the People
Patterns for the PeopleKevlin Henney
 
An Empirical Study on Inconsistent Changes to Code Clones at Release Level
An Empirical Study on Inconsistent Changes to Code Clones at Release LevelAn Empirical Study on Inconsistent Changes to Code Clones at Release Level
An Empirical Study on Inconsistent Changes to Code Clones at Release LevelNicolas Bettenburg
 
YOOX Launch & Learn - Javascript as a programming language
 YOOX Launch & Learn - Javascript as a programming language YOOX Launch & Learn - Javascript as a programming language
YOOX Launch & Learn - Javascript as a programming languageMarco Cedaro
 
Continuous Automated Testing - Cast conference workshop august 2014
Continuous Automated Testing - Cast conference workshop august 2014Continuous Automated Testing - Cast conference workshop august 2014
Continuous Automated Testing - Cast conference workshop august 2014Noah Sussman
 
Dip(dependency inversion principle) presentation
Dip(dependency inversion principle) presentationDip(dependency inversion principle) presentation
Dip(dependency inversion principle) presentationqamar mustafa
 

Similar to The Zen of IoC (20)

Dependency Inversion in large-scale TypeScript applications with InversifyJS
Dependency Inversion in large-scale TypeScript applications with InversifyJSDependency Inversion in large-scale TypeScript applications with InversifyJS
Dependency Inversion in large-scale TypeScript applications with InversifyJS
 
DevSecCon London 2017: The flaws in hordes, the security in crowds by Mike Shema
DevSecCon London 2017: The flaws in hordes, the security in crowds by Mike ShemaDevSecCon London 2017: The flaws in hordes, the security in crowds by Mike Shema
DevSecCon London 2017: The flaws in hordes, the security in crowds by Mike Shema
 
Oleksandr Valetskyy - Become a .NET dependency injection ninja with Ninject
Oleksandr Valetskyy - Become a .NET dependency injection ninja with NinjectOleksandr Valetskyy - Become a .NET dependency injection ninja with Ninject
Oleksandr Valetskyy - Become a .NET dependency injection ninja with Ninject
 
10 Reasons Your Software Sucks - Election 2012 Edition
10 Reasons Your Software Sucks - Election 2012 Edition10 Reasons Your Software Sucks - Election 2012 Edition
10 Reasons Your Software Sucks - Election 2012 Edition
 
Variability, Bugs, and Cognition
Variability, Bugs, and CognitionVariability, Bugs, and Cognition
Variability, Bugs, and Cognition
 
Dependency injection
Dependency injectionDependency injection
Dependency injection
 
Dependency Injection Lightning Talk
Dependency Injection Lightning TalkDependency Injection Lightning Talk
Dependency Injection Lightning Talk
 
10 practices that every developer needs to start right now
10 practices that every developer needs to start right now10 practices that every developer needs to start right now
10 practices that every developer needs to start right now
 
Dependency Inversion Principle
Dependency Inversion PrincipleDependency Inversion Principle
Dependency Inversion Principle
 
Developer Job in Practice
Developer Job in PracticeDeveloper Job in Practice
Developer Job in Practice
 
KevlinHenney_PuttingThereIntoArchitecture
KevlinHenney_PuttingThereIntoArchitectureKevlinHenney_PuttingThereIntoArchitecture
KevlinHenney_PuttingThereIntoArchitecture
 
Continuous integration 101
Continuous integration 101Continuous integration 101
Continuous integration 101
 
Cyber security innovation imho
Cyber security innovation imhoCyber security innovation imho
Cyber security innovation imho
 
Togetherlearn Learntrends
Togetherlearn LearntrendsTogetherlearn Learntrends
Togetherlearn Learntrends
 
Patterns for the People
Patterns for the PeoplePatterns for the People
Patterns for the People
 
An Empirical Study on Inconsistent Changes to Code Clones at Release Level
An Empirical Study on Inconsistent Changes to Code Clones at Release LevelAn Empirical Study on Inconsistent Changes to Code Clones at Release Level
An Empirical Study on Inconsistent Changes to Code Clones at Release Level
 
YOOX Launch & Learn - Javascript as a programming language
 YOOX Launch & Learn - Javascript as a programming language YOOX Launch & Learn - Javascript as a programming language
YOOX Launch & Learn - Javascript as a programming language
 
Continuous Automated Testing - Cast conference workshop august 2014
Continuous Automated Testing - Cast conference workshop august 2014Continuous Automated Testing - Cast conference workshop august 2014
Continuous Automated Testing - Cast conference workshop august 2014
 
Dip(dependency inversion principle) presentation
Dip(dependency inversion principle) presentationDip(dependency inversion principle) presentation
Dip(dependency inversion principle) presentation
 
Integreation
IntegreationIntegreation
Integreation
 

Recently uploaded

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 

Recently uploaded (20)

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

The Zen of IoC