SlideShare a Scribd company logo
1 of 10
C# in 20 Minutes
Dependency Injection
Thomas Mentzel
blog.softwarekueche.de
How to explain dependency
injection to a 5-year old?
• When you go and get things out of the refrigerator for
yourself, you can cause problems. You might leave the
door open, you might get something Mommy or Daddy
doesn't want you to have. You might even be looking for
something we don't even have or which has expired.
• What you should be doing is stating a need, "I need
something to drink with lunch," and then we will make
sure you have something [proper] when you sit down to
eat.
StackOverflow (http://bit.ly/1mBlD78)
TemplateEditor right now…
…refactors to Interfaces…
… and ends up with
Dependency Injection
Dependency Injection Container
Injection Methods
• Constructor Injection
– constructor parameter
– required dependencies
• Property Injection
– properties/setter
– optional parameter
– null-object pattern
Supportive Frameworks
• Caliburn Micro for WPF
• ASP.NET MVC Built-In
• Prism for Silverlight
• …and many many more
You should know …
• … what Dependency Injection is
• … what a DI Container is
• … what the difference between
Constructor Injection and Property
Injection is
• … what inversion of control means
• … when to use Dependency Injection
Fragen?!
• Thomas Mentzel
• blog.softwarekueche.de
• thomas.mentzel@softwarekueche.de
• @ThomasMentzel
• Google: Thomas Mentzel, Hennef

More Related Content

More from Thomas Mentzel

More from Thomas Mentzel (14)

Sitzen ist das neue Rauchen - Kurzpräsentation
Sitzen ist das neue Rauchen - KurzpräsentationSitzen ist das neue Rauchen - Kurzpräsentation
Sitzen ist das neue Rauchen - Kurzpräsentation
 
An Introduction to Clean Code Developer
An Introduction to Clean Code DeveloperAn Introduction to Clean Code Developer
An Introduction to Clean Code Developer
 
O/R Mapping Einführung
O/R Mapping EinführungO/R Mapping Einführung
O/R Mapping Einführung
 
Word 2007 Einführung - Tag 04
Word 2007 Einführung - Tag 04Word 2007 Einführung - Tag 04
Word 2007 Einführung - Tag 04
 
Word 2007 Einführung 03 - Tag 03
Word 2007 Einführung 03 - Tag 03Word 2007 Einführung 03 - Tag 03
Word 2007 Einführung 03 - Tag 03
 
Word 2007 Einführung 02 - Tag 02
Word 2007 Einführung 02 - Tag 02Word 2007 Einführung 02 - Tag 02
Word 2007 Einführung 02 - Tag 02
 
Word 2007 Einführung 01 - Tag 1
Word 2007 Einführung 01 - Tag 1Word 2007 Einführung 01 - Tag 1
Word 2007 Einführung 01 - Tag 1
 
Word 2007 Einführung 00 - Agenda
Word 2007 Einführung 00 - AgendaWord 2007 Einführung 00 - Agenda
Word 2007 Einführung 00 - Agenda
 
Productivity- and Self Management
Productivity- and Self ManagementProductivity- and Self Management
Productivity- and Self Management
 
Logging mit log4net
Logging mit log4netLogging mit log4net
Logging mit log4net
 
Einführung Team Foundation Server 2010
Einführung Team Foundation Server 2010Einführung Team Foundation Server 2010
Einführung Team Foundation Server 2010
 
AOP mit PostSharp
AOP mit PostSharpAOP mit PostSharp
AOP mit PostSharp
 
Varianten des "Observer Pattern"
Varianten des "Observer Pattern"Varianten des "Observer Pattern"
Varianten des "Observer Pattern"
 
10000 Schritte - Was steckt dahinter
10000 Schritte - Was steckt dahinter10000 Schritte - Was steckt dahinter
10000 Schritte - Was steckt dahinter
 

Recently uploaded

Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
FIDO Alliance
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
FIDO Alliance
 
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
UK Journal
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
FIDO Alliance
 

Recently uploaded (20)

How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform Engineering
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
2024 May Patch Tuesday
2024 May Patch Tuesday2024 May Patch Tuesday
2024 May Patch Tuesday
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 

C# in 20 Minutes: Dependency Injection

  • 1. C# in 20 Minutes Dependency Injection Thomas Mentzel blog.softwarekueche.de
  • 2. How to explain dependency injection to a 5-year old? • When you go and get things out of the refrigerator for yourself, you can cause problems. You might leave the door open, you might get something Mommy or Daddy doesn't want you to have. You might even be looking for something we don't even have or which has expired. • What you should be doing is stating a need, "I need something to drink with lunch," and then we will make sure you have something [proper] when you sit down to eat. StackOverflow (http://bit.ly/1mBlD78)
  • 5. … and ends up with Dependency Injection
  • 7. Injection Methods • Constructor Injection – constructor parameter – required dependencies • Property Injection – properties/setter – optional parameter – null-object pattern
  • 8. Supportive Frameworks • Caliburn Micro for WPF • ASP.NET MVC Built-In • Prism for Silverlight • …and many many more
  • 9. You should know … • … what Dependency Injection is • … what a DI Container is • … what the difference between Constructor Injection and Property Injection is • … what inversion of control means • … when to use Dependency Injection
  • 10. Fragen?! • Thomas Mentzel • blog.softwarekueche.de • thomas.mentzel@softwarekueche.de • @ThomasMentzel • Google: Thomas Mentzel, Hennef