SlideShare uma empresa Scribd logo
1 de 17
Dependency Injection 
Design Principles and Patterns 
Part I 
Prepared by 
Juan Lopez, Software Developer 
October 29, 2014
Overview 
Successful software must be able to change. 
The purpose of most programming techniques is to deliver working 
maintainable software as efficiently as possible. 
Writing well-crafted and self-explanatory software is almost as important as 
writing working software. 
One of many ways to make code maintainable is through loose coupling. Loose 
coupling makes code extensible, and extensibility makes it maintainable.
What is Dependency Injection? 
Dependency Injection is a set of object-oriented programming and design 
principles and patterns. 
Wikipedia: 
Dependency Injection is a set of software design patterns that implements 
inversion of control and allows a program design to follow the dependency 
inversion principle. 
Mark Seemann: 
Dependency Injection is a set of software design principles and patterns that 
enable us to develop loosely coupled code.
SOLID Principles 
✓ Single Responsibility 
✓ Open-closed 
✓ Liskov substitution 
✓ Interface segregation 
✓ Dependency Inversion
Design Patterns 
✓ Adapter or wrapper pattern 
✓ Bridge pattern 
✓ Composite pattern 
✓ Decorator pattern
Dependency Injection 
DI enables loose coupling, and loose coupling makes code more maintainable. 
DI is a means to an end. DI also enables us to better manage futures changes 
and other complexities in our software. 
DI is more about abstract thinking and design code than it is about tools and 
techniques.
Single Responsibility Principle 
Maintainability is a benefit of the SINGLE RESPONSIBILITY PRINCIPLE, 
which states that each class should have a single responsibility. Classes 
should only deal with their given area of responsibility, without concerning 
themselves with how DEPENDENCIES are created. 
An important element of DI is to break up various responsibilities into 
separate classes. One responsibility we take away from is the task of creating 
instances of DEPENDENCIES.
Open/Closed Principle 
Software entities should be open for extension but closed for modifications. 
Loose coupling enables us to write code which is open for extensibility, but 
closed for modifications, that is, such an entity can allow its behaviour to be 
modified without altering its source code. 
The implementation of a class could only be modified to correct errors; new or 
changed features would require that a different class be created. Don’t change 
existing code, instead add new classes and recompose the application.
Liskov substitution principle 
Objects in a program should be replaceable with instances of their subtypes 
without altering the correctness of that program. 
A client should not care about the concrete types of its DEPENDENCIES.
Interface Segregation Principle 
Many client specific interfaces are better than one general purpose interface. 
No client should be forced to depend on methods it does not use. 
ISP splits interfaces which are very large into smaller and more specific ones 
so that clients will only have to know about the methods that are of interest to 
them.
Dependency Inversion 
Principle 
Depend upon abstractions. Do not depend upon concretions. 
Program to an interface, not an implementation. 
The most prevalent benefit of programming to interfaces, is the ability to swap 
out one service with another.
Design Patterns 
✓ Adapter or wrapper pattern 
✓ Bridge pattern 
✓ Composite pattern
Adapter Pattern 
The Adapter Design Pattern allows the interface of an existing class to be 
used from another interface. It is often to make existing classes work with 
others without modifying their source code. 
An adapter helps two incompatible interfaces to work together by converting 
the interface of one class into one expected by the client. 
The adapter pattern is useful in situations where an already existing class 
provides some or all of the services you need but does not the interface you 
need.
Bridge Pattern 
The Bridge Pattern is design to “decouple an abstraction from its 
implementation so that the two can vary independently.” 
The bridge pattern is useful when both the class and as well as what it does 
vary often. The class itself can be thought as the implementation and what the 
class can do as the abstraction.
Composite Pattern 
When we aggregate several implementations in one, we use the Composite 
Pattern. The Composite Pattern describes that a group of objects is to be 
treated same way as a single instance of an object. The intent of a composite is 
to “compose” objects into tree structures to represent part-whole hierarchies. 
Favor composition over class inheritance.
Conclusion 
The consequences of poor system design, software architecture or software 
developer is Technical Debt. 
If the debt is not paid, then it will keep on accumulating interest, making it hard 
to implement changes later on. 
more code to write = more code to test = more code to debug = more code to maintain 
One of many ways to make code maintainable is through loose coupling. Loose 
coupling makes code extensible, and extensibility makes it maintainable. 
Dependency Injection enables loose coupling.
References 
✓ http://en.wikipedia.org/wiki/Software_design_pattern 
✓ Dependency Injection in .NET by Mark Seemann

Mais conteúdo relacionado

Mais procurados

.NET Architecture for Enterprises
.NET Architecture for Enterprises.NET Architecture for Enterprises
.NET Architecture for EnterprisesWade Wegner
 
How do i implement command design pattern in the java programming course with...
How do i implement command design pattern in the java programming course with...How do i implement command design pattern in the java programming course with...
How do i implement command design pattern in the java programming course with...kritikumar16
 
Refreshing Domain Driven Design
Refreshing Domain Driven DesignRefreshing Domain Driven Design
Refreshing Domain Driven DesignAndré Borgonovo
 
TorontoRb Intro to BDD
TorontoRb   Intro to BDDTorontoRb   Intro to BDD
TorontoRb Intro to BDDnunick
 

Mais procurados (9)

MEAN (DevFM)
MEAN (DevFM)MEAN (DevFM)
MEAN (DevFM)
 
.NET Architecture for Enterprises
.NET Architecture for Enterprises.NET Architecture for Enterprises
.NET Architecture for Enterprises
 
SRP Everywhere
SRP EverywhereSRP Everywhere
SRP Everywhere
 
Thoughtful Software Design
Thoughtful Software DesignThoughtful Software Design
Thoughtful Software Design
 
How do i implement command design pattern in the java programming course with...
How do i implement command design pattern in the java programming course with...How do i implement command design pattern in the java programming course with...
How do i implement command design pattern in the java programming course with...
 
Ide presentation
Ide presentationIde presentation
Ide presentation
 
Refreshing Domain Driven Design
Refreshing Domain Driven DesignRefreshing Domain Driven Design
Refreshing Domain Driven Design
 
TorontoRb Intro to BDD
TorontoRb   Intro to BDDTorontoRb   Intro to BDD
TorontoRb Intro to BDD
 
Resume
ResumeResume
Resume
 

Destaque

azure track -06- cloud integration patterns for it-pros - itproceed
azure track -06- cloud integration patterns for it-pros - itproceedazure track -06- cloud integration patterns for it-pros - itproceed
azure track -06- cloud integration patterns for it-pros - itproceedITProceed
 
Windows Azure Design Patterns
Windows Azure Design PatternsWindows Azure Design Patterns
Windows Azure Design PatternsDavid Pallmann
 
DesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsDesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsBasavaraj Patil
 
Cloud architectural patterns and Microsoft Azure tools
Cloud architectural patterns and Microsoft Azure toolsCloud architectural patterns and Microsoft Azure tools
Cloud architectural patterns and Microsoft Azure toolsPushkar Chivate
 
Design Pattern that every cloud developer must know
Design Pattern that every cloud developer must know Design Pattern that every cloud developer must know
Design Pattern that every cloud developer must know Shahriar Iqbal Chowdhury
 
Azure Cloud Patterns
Azure Cloud PatternsAzure Cloud Patterns
Azure Cloud PatternsTamir Dresher
 
Microsoft cloud integration patterns - BizTalk/Azure
Microsoft cloud integration patterns - BizTalk/AzureMicrosoft cloud integration patterns - BizTalk/Azure
Microsoft cloud integration patterns - BizTalk/AzureNikolai Blackie
 
Integration patterns and practices for cloud and mobile computing
Integration patterns and practices for cloud and mobile computingIntegration patterns and practices for cloud and mobile computing
Integration patterns and practices for cloud and mobile computingSHAKIL AKHTAR
 
Cloud integration patterns, technologies & trends
Cloud integration patterns, technologies & trendsCloud integration patterns, technologies & trends
Cloud integration patterns, technologies & trendsRichard Seroter
 
Windows Azure Queues and Windows Azure Service Bus Queues
Windows Azure Queues and Windows Azure Service Bus QueuesWindows Azure Queues and Windows Azure Service Bus Queues
Windows Azure Queues and Windows Azure Service Bus QueuesJuan Pablo
 
The Art of Scalability - Managing growth
The Art of Scalability - Managing growthThe Art of Scalability - Managing growth
The Art of Scalability - Managing growthLorenzo Alberton
 
Web architecture pocket guide
Web architecture pocket guideWeb architecture pocket guide
Web architecture pocket guidemeroooo
 
Cloud Computing Architecture
Cloud Computing Architecture Cloud Computing Architecture
Cloud Computing Architecture Vasu Jain
 
Microsoft azure overview
Microsoft azure overviewMicrosoft azure overview
Microsoft azure overviewAli Mkahal
 
Distributed Design and Architecture of Cloud Foundry
Distributed Design and Architecture of Cloud FoundryDistributed Design and Architecture of Cloud Foundry
Distributed Design and Architecture of Cloud FoundryDerek Collison
 
Cloud Computing Architecture Primer
Cloud Computing Architecture PrimerCloud Computing Architecture Primer
Cloud Computing Architecture PrimerIlham Ahmed
 
Secure by Design - Security Design Principles for the Rest of Us
Secure by Design - Security Design Principles for the Rest of UsSecure by Design - Security Design Principles for the Rest of Us
Secure by Design - Security Design Principles for the Rest of UsEoin Woods
 

Destaque (20)

azure track -06- cloud integration patterns for it-pros - itproceed
azure track -06- cloud integration patterns for it-pros - itproceedazure track -06- cloud integration patterns for it-pros - itproceed
azure track -06- cloud integration patterns for it-pros - itproceed
 
Windows Azure Design Patterns
Windows Azure Design PatternsWindows Azure Design Patterns
Windows Azure Design Patterns
 
Azure and cloud design patterns
Azure and cloud design patternsAzure and cloud design patterns
Azure and cloud design patterns
 
Building Scalable and Robust Solutions with Service Bus in Cloud and Server
Building Scalable and Robust Solutions with Service Bus in Cloud and ServerBuilding Scalable and Robust Solutions with Service Bus in Cloud and Server
Building Scalable and Robust Solutions with Service Bus in Cloud and Server
 
DesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsDesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatterns
 
Cloud architectural patterns and Microsoft Azure tools
Cloud architectural patterns and Microsoft Azure toolsCloud architectural patterns and Microsoft Azure tools
Cloud architectural patterns and Microsoft Azure tools
 
Design Pattern that every cloud developer must know
Design Pattern that every cloud developer must know Design Pattern that every cloud developer must know
Design Pattern that every cloud developer must know
 
Azure Cloud Patterns
Azure Cloud PatternsAzure Cloud Patterns
Azure Cloud Patterns
 
Microsoft cloud integration patterns - BizTalk/Azure
Microsoft cloud integration patterns - BizTalk/AzureMicrosoft cloud integration patterns - BizTalk/Azure
Microsoft cloud integration patterns - BizTalk/Azure
 
Integration patterns and practices for cloud and mobile computing
Integration patterns and practices for cloud and mobile computingIntegration patterns and practices for cloud and mobile computing
Integration patterns and practices for cloud and mobile computing
 
Cloud integration patterns, technologies & trends
Cloud integration patterns, technologies & trendsCloud integration patterns, technologies & trends
Cloud integration patterns, technologies & trends
 
Windows Azure Queues and Windows Azure Service Bus Queues
Windows Azure Queues and Windows Azure Service Bus QueuesWindows Azure Queues and Windows Azure Service Bus Queues
Windows Azure Queues and Windows Azure Service Bus Queues
 
The Art of Scalability - Managing growth
The Art of Scalability - Managing growthThe Art of Scalability - Managing growth
The Art of Scalability - Managing growth
 
Web architecture pocket guide
Web architecture pocket guideWeb architecture pocket guide
Web architecture pocket guide
 
Cloud Computing Architecture
Cloud Computing ArchitectureCloud Computing Architecture
Cloud Computing Architecture
 
Cloud Computing Architecture
Cloud Computing Architecture Cloud Computing Architecture
Cloud Computing Architecture
 
Microsoft azure overview
Microsoft azure overviewMicrosoft azure overview
Microsoft azure overview
 
Distributed Design and Architecture of Cloud Foundry
Distributed Design and Architecture of Cloud FoundryDistributed Design and Architecture of Cloud Foundry
Distributed Design and Architecture of Cloud Foundry
 
Cloud Computing Architecture Primer
Cloud Computing Architecture PrimerCloud Computing Architecture Primer
Cloud Computing Architecture Primer
 
Secure by Design - Security Design Principles for the Rest of Us
Secure by Design - Security Design Principles for the Rest of UsSecure by Design - Security Design Principles for the Rest of Us
Secure by Design - Security Design Principles for the Rest of Us
 

Semelhante a Dependency Injection, Design Principles and Patterns

Software design principles - jinal desai
Software design principles - jinal desaiSoftware design principles - jinal desai
Software design principles - jinal desaijinaldesailive
 
Code Craftsmanship Checklist
Code Craftsmanship ChecklistCode Craftsmanship Checklist
Code Craftsmanship ChecklistRyan Polk
 
Object Oriented Design SOLID Principles
Object Oriented Design SOLID PrinciplesObject Oriented Design SOLID Principles
Object Oriented Design SOLID Principlesrainynovember12
 
SOLID Design Principles for Test Automaion
SOLID Design Principles for Test AutomaionSOLID Design Principles for Test Automaion
SOLID Design Principles for Test AutomaionKnoldus Inc.
 
Java TechTalk "Spring boot made life easier with Kubernetes and Microservices"
Java TechTalk "Spring boot made life easier with Kubernetes and Microservices"Java TechTalk "Spring boot made life easier with Kubernetes and Microservices"
Java TechTalk "Spring boot made life easier with Kubernetes and Microservices"GlobalLogic Ukraine
 
10 Programming Principles Every Software Developer Should Know.pdf
10 Programming Principles Every Software Developer Should Know.pdf10 Programming Principles Every Software Developer Should Know.pdf
10 Programming Principles Every Software Developer Should Know.pdfBMN Infotech
 
Solid OO & Clean Coding is essential to successful Agile development
Solid OO & Clean Coding is essential to successful Agile developmentSolid OO & Clean Coding is essential to successful Agile development
Solid OO & Clean Coding is essential to successful Agile developmentSimon Gould
 
Software development philosophies v1
Software development philosophies v1Software development philosophies v1
Software development philosophies v1Praveen Nair
 
Test Driven Development:Unit Testing, Dependency Injection, Mocking
Test Driven Development:Unit Testing, Dependency Injection, MockingTest Driven Development:Unit Testing, Dependency Injection, Mocking
Test Driven Development:Unit Testing, Dependency Injection, Mockingmrjawright
 
Devops Explained & Best Practices
Devops Explained & Best PracticesDevops Explained & Best Practices
Devops Explained & Best PracticesShikhaKonda
 
Le cloudvupardesexperts 9pov-curationparloicsimon-clubclouddespartenaires
Le cloudvupardesexperts 9pov-curationparloicsimon-clubclouddespartenairesLe cloudvupardesexperts 9pov-curationparloicsimon-clubclouddespartenaires
Le cloudvupardesexperts 9pov-curationparloicsimon-clubclouddespartenairesClub Alliances
 
Reusability Vs Extensibility and Methodologies in OOAD
Reusability Vs Extensibility and Methodologies in OOADReusability Vs Extensibility and Methodologies in OOAD
Reusability Vs Extensibility and Methodologies in OOADSayyada Ayesha
 

Semelhante a Dependency Injection, Design Principles and Patterns (20)

Software design principles - jinal desai
Software design principles - jinal desaiSoftware design principles - jinal desai
Software design principles - jinal desai
 
Solid
SolidSolid
Solid
 
Code Craftsmanship Checklist
Code Craftsmanship ChecklistCode Craftsmanship Checklist
Code Craftsmanship Checklist
 
Android architecture
Android architectureAndroid architecture
Android architecture
 
Object Oriented Design SOLID Principles
Object Oriented Design SOLID PrinciplesObject Oriented Design SOLID Principles
Object Oriented Design SOLID Principles
 
SOLID Design Principles for Test Automaion
SOLID Design Principles for Test AutomaionSOLID Design Principles for Test Automaion
SOLID Design Principles for Test Automaion
 
Java TechTalk "Spring boot made life easier with Kubernetes and Microservices"
Java TechTalk "Spring boot made life easier with Kubernetes and Microservices"Java TechTalk "Spring boot made life easier with Kubernetes and Microservices"
Java TechTalk "Spring boot made life easier with Kubernetes and Microservices"
 
10 Programming Principles Every Software Developer Should Know.pdf
10 Programming Principles Every Software Developer Should Know.pdf10 Programming Principles Every Software Developer Should Know.pdf
10 Programming Principles Every Software Developer Should Know.pdf
 
Solid OO & Clean Coding is essential to successful Agile development
Solid OO & Clean Coding is essential to successful Agile developmentSolid OO & Clean Coding is essential to successful Agile development
Solid OO & Clean Coding is essential to successful Agile development
 
Software development philosophies v1
Software development philosophies v1Software development philosophies v1
Software development philosophies v1
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean Architecture
 
OO Design Principles
OO Design PrinciplesOO Design Principles
OO Design Principles
 
Test Driven Development:Unit Testing, Dependency Injection, Mocking
Test Driven Development:Unit Testing, Dependency Injection, MockingTest Driven Development:Unit Testing, Dependency Injection, Mocking
Test Driven Development:Unit Testing, Dependency Injection, Mocking
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Devops Explained & Best Practices
Devops Explained & Best PracticesDevops Explained & Best Practices
Devops Explained & Best Practices
 
Le cloudvupardesexperts 9pov-curationparloicsimon-clubclouddespartenaires
Le cloudvupardesexperts 9pov-curationparloicsimon-clubclouddespartenairesLe cloudvupardesexperts 9pov-curationparloicsimon-clubclouddespartenaires
Le cloudvupardesexperts 9pov-curationparloicsimon-clubclouddespartenaires
 
android principle.pptx
android principle.pptxandroid principle.pptx
android principle.pptx
 
Reusability Vs Extensibility and Methodologies in OOAD
Reusability Vs Extensibility and Methodologies in OOADReusability Vs Extensibility and Methodologies in OOAD
Reusability Vs Extensibility and Methodologies in OOAD
 
Devops ppt
Devops pptDevops ppt
Devops ppt
 
Software Engineering CSE/IT.pptx
 Software Engineering CSE/IT.pptx Software Engineering CSE/IT.pptx
Software Engineering CSE/IT.pptx
 

Último

Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 

Último (20)

Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 

Dependency Injection, Design Principles and Patterns

  • 1. Dependency Injection Design Principles and Patterns Part I Prepared by Juan Lopez, Software Developer October 29, 2014
  • 2. Overview Successful software must be able to change. The purpose of most programming techniques is to deliver working maintainable software as efficiently as possible. Writing well-crafted and self-explanatory software is almost as important as writing working software. One of many ways to make code maintainable is through loose coupling. Loose coupling makes code extensible, and extensibility makes it maintainable.
  • 3. What is Dependency Injection? Dependency Injection is a set of object-oriented programming and design principles and patterns. Wikipedia: Dependency Injection is a set of software design patterns that implements inversion of control and allows a program design to follow the dependency inversion principle. Mark Seemann: Dependency Injection is a set of software design principles and patterns that enable us to develop loosely coupled code.
  • 4. SOLID Principles ✓ Single Responsibility ✓ Open-closed ✓ Liskov substitution ✓ Interface segregation ✓ Dependency Inversion
  • 5. Design Patterns ✓ Adapter or wrapper pattern ✓ Bridge pattern ✓ Composite pattern ✓ Decorator pattern
  • 6. Dependency Injection DI enables loose coupling, and loose coupling makes code more maintainable. DI is a means to an end. DI also enables us to better manage futures changes and other complexities in our software. DI is more about abstract thinking and design code than it is about tools and techniques.
  • 7. Single Responsibility Principle Maintainability is a benefit of the SINGLE RESPONSIBILITY PRINCIPLE, which states that each class should have a single responsibility. Classes should only deal with their given area of responsibility, without concerning themselves with how DEPENDENCIES are created. An important element of DI is to break up various responsibilities into separate classes. One responsibility we take away from is the task of creating instances of DEPENDENCIES.
  • 8. Open/Closed Principle Software entities should be open for extension but closed for modifications. Loose coupling enables us to write code which is open for extensibility, but closed for modifications, that is, such an entity can allow its behaviour to be modified without altering its source code. The implementation of a class could only be modified to correct errors; new or changed features would require that a different class be created. Don’t change existing code, instead add new classes and recompose the application.
  • 9. Liskov substitution principle Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program. A client should not care about the concrete types of its DEPENDENCIES.
  • 10. Interface Segregation Principle Many client specific interfaces are better than one general purpose interface. No client should be forced to depend on methods it does not use. ISP splits interfaces which are very large into smaller and more specific ones so that clients will only have to know about the methods that are of interest to them.
  • 11. Dependency Inversion Principle Depend upon abstractions. Do not depend upon concretions. Program to an interface, not an implementation. The most prevalent benefit of programming to interfaces, is the ability to swap out one service with another.
  • 12. Design Patterns ✓ Adapter or wrapper pattern ✓ Bridge pattern ✓ Composite pattern
  • 13. Adapter Pattern The Adapter Design Pattern allows the interface of an existing class to be used from another interface. It is often to make existing classes work with others without modifying their source code. An adapter helps two incompatible interfaces to work together by converting the interface of one class into one expected by the client. The adapter pattern is useful in situations where an already existing class provides some or all of the services you need but does not the interface you need.
  • 14. Bridge Pattern The Bridge Pattern is design to “decouple an abstraction from its implementation so that the two can vary independently.” The bridge pattern is useful when both the class and as well as what it does vary often. The class itself can be thought as the implementation and what the class can do as the abstraction.
  • 15. Composite Pattern When we aggregate several implementations in one, we use the Composite Pattern. The Composite Pattern describes that a group of objects is to be treated same way as a single instance of an object. The intent of a composite is to “compose” objects into tree structures to represent part-whole hierarchies. Favor composition over class inheritance.
  • 16. Conclusion The consequences of poor system design, software architecture or software developer is Technical Debt. If the debt is not paid, then it will keep on accumulating interest, making it hard to implement changes later on. more code to write = more code to test = more code to debug = more code to maintain One of many ways to make code maintainable is through loose coupling. Loose coupling makes code extensible, and extensibility makes it maintainable. Dependency Injection enables loose coupling.
  • 17. References ✓ http://en.wikipedia.org/wiki/Software_design_pattern ✓ Dependency Injection in .NET by Mark Seemann