SlideShare a Scribd company logo
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

More Related Content

What's hot

MEAN (DevFM)
MEAN (DevFM)MEAN (DevFM)
MEAN (DevFM)
Fabian Vilers
 
.NET Architecture for Enterprises
.NET Architecture for Enterprises.NET Architecture for Enterprises
.NET Architecture for Enterprises
Wade Wegner
 
SRP Everywhere
SRP EverywhereSRP Everywhere
SRP Everywhere
Gourav Tiwari
 
Thoughtful Software Design
Thoughtful Software DesignThoughtful Software Design
Thoughtful Software Design
Giovanni Scerra ☃
 
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
 
Ide presentation
Ide presentationIde presentation
Ide presentation
Viswanath Polaki
 
Refreshing Domain Driven Design
Refreshing Domain Driven DesignRefreshing Domain Driven Design
Refreshing Domain Driven Design
André Borgonovo
 
TorontoRb Intro to BDD
TorontoRb   Intro to BDDTorontoRb   Intro to BDD
TorontoRb Intro to BDD
nunick
 
Resume
ResumeResume
Resume
Pappu Kumar
 

What's hot (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
 

Viewers also liked

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
ITProceed
 
Windows Azure Design Patterns
Windows Azure Design PatternsWindows Azure Design Patterns
Windows Azure Design Patterns
David Pallmann
 
Azure and cloud design patterns
Azure and cloud design patternsAzure and cloud design patterns
Azure and cloud design patterns
Venkatesh Narayanan
 
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
Microsoft Developer Network (MSDN) - Belgium and Luxembourg
 
DesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsDesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatterns
Basavaraj 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 tools
Pushkar 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 Patterns
Tamir Dresher
 
Microsoft cloud integration patterns - BizTalk/Azure
Microsoft cloud integration patterns - BizTalk/AzureMicrosoft cloud integration patterns - BizTalk/Azure
Microsoft cloud integration patterns - BizTalk/Azure
Nikolai 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 computing
SHAKIL AKHTAR
 
Cloud integration patterns, technologies & trends
Cloud integration patterns, technologies & trendsCloud integration patterns, technologies & trends
Cloud integration patterns, technologies & trends
Richard 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 Queues
Juan Pablo
 
The Art of Scalability - Managing growth
The Art of Scalability - Managing growthThe Art of Scalability - Managing growth
The Art of Scalability - Managing growth
Lorenzo Alberton
 
Web architecture pocket guide
Web architecture pocket guideWeb architecture pocket guide
Web architecture pocket guide
meroooo
 
Cloud Computing Architecture
Cloud Computing ArchitectureCloud Computing Architecture
Cloud Computing Architecture
Animesh Chaturvedi
 
Cloud Computing Architecture
Cloud Computing Architecture Cloud Computing Architecture
Cloud Computing Architecture
Vasu Jain
 
Microsoft azure overview
Microsoft azure overviewMicrosoft azure overview
Microsoft azure overview
Ali 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 Foundry
Derek Collison
 
Cloud Computing Architecture Primer
Cloud Computing Architecture PrimerCloud Computing Architecture Primer
Cloud Computing Architecture Primer
Ilham 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 Us
Eoin Woods
 

Viewers also liked (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
 

Similar to Dependency Injection, Design Principles and Patterns

Software design principles - jinal desai
Software design principles - jinal desaiSoftware design principles - jinal desai
Software design principles - jinal desai
jinaldesailive
 
Solid
SolidSolid
Code Craftsmanship Checklist
Code Craftsmanship ChecklistCode Craftsmanship Checklist
Code Craftsmanship Checklist
Ryan Polk
 
Android architecture
Android architectureAndroid architecture
Android architecture
Vandana Srivastava
 
Object Oriented Design SOLID Principles
Object Oriented Design SOLID PrinciplesObject Oriented Design SOLID Principles
Object Oriented Design SOLID Principles
rainynovember12
 
SOLID Design Principles for Test Automaion
SOLID Design Principles for Test AutomaionSOLID Design Principles for Test Automaion
SOLID Design Principles for Test Automaion
Knoldus 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.pdf
BMN 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 development
Simon Gould
 
Software development philosophies v1
Software development philosophies v1Software development philosophies v1
Software development philosophies v1
Praveen Nair
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean Architecture
NSCoder Mexico
 
OO Design Principles
OO Design PrinciplesOO Design Principles
OO Design Principles
Anju Kanjirathingal
 
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
mrjawright
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
Harsh Jegadeesan
 
Devops Explained & Best Practices
Devops Explained & Best PracticesDevops Explained & Best Practices
Devops Explained & Best Practices
ShikhaKonda
 
Le cloudvupardesexperts 9pov-curationparloicsimon-clubclouddespartenaires
Le cloudvupardesexperts 9pov-curationparloicsimon-clubclouddespartenairesLe cloudvupardesexperts 9pov-curationparloicsimon-clubclouddespartenaires
Le cloudvupardesexperts 9pov-curationparloicsimon-clubclouddespartenaires
Club Alliances
 
android principle.pptx
android principle.pptxandroid principle.pptx
android principle.pptx
debasish duarah
 
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
Sayyada Ayesha
 
Devops ppt
Devops pptDevops ppt
Devops ppt
sterlingit
 
Software Engineering CSE/IT.pptx
 Software Engineering CSE/IT.pptx Software Engineering CSE/IT.pptx
Software Engineering CSE/IT.pptx
TheULTIMATEALLROUNDE
 

Similar to 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
 

Recently uploaded

Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
kalichargn70th171
 
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise EditionWhy Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Envertis Software Solutions
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
Hironori Washizaki
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
rodomar2
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
Alina Yurenko
 

Recently uploaded (20)

Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
 
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise EditionWhy Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
 

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