SlideShare a Scribd company logo
1 of 10
SOLID Principles - III
DIP – Dependency Inversion Principle
Maulik Soni
Dependency Inversion Principle
 High-level modules should not depend on low-level modules
 Both should depend on abstractions
 Abstractions should not depend on details
 Details should depend on abstractions
Maulik Soni
Dependency Inversion Principle
DIP is at the very heart of framework design
Maulik Soni
How To Spot DIP Violation ?
 Direct Instantiation
 new SomeObject();
 Static Methods
 ServiceLocator.getObject();
Maulik Soni
Is DIP Violated Here ?
Maulik Soni
Resolution
Maulik Soni
Inverted Dependencies
Maulik Soni
Demo
 Demo of DIP and Dependency Injection using Unity
Maulik Soni
Summary
 Depend on abstractions
 No variable should hold a reference to a concrete class
 No class should derive from a concrete class
 No method should override an implemented method of any of its base classes
 Heuristic is typically violated at least once
 Somebody has to create the instances of the concrete classes
 No reason to strictly follow this heuristic for classes that are concrete but non-volatile
Maulik Soni
End of Presentation
Maulik Soni
 End of Introduction to SOLID Principles
 S = Single Responsibility
 O = Open / Closed
 L = Liskov Substitution
 I = Interface Segregation
 D = Dependency Inversion

More Related Content

Similar to SOLID Principles Part 3 (9)

Dependency inversion
Dependency inversionDependency inversion
Dependency inversion
 
OO design principle
OO design principleOO design principle
OO design principle
 
Dependency Inversion
Dependency InversionDependency Inversion
Dependency Inversion
 
Solid Principles
Solid PrinciplesSolid Principles
Solid Principles
 
Clean code: SOLID
Clean code: SOLIDClean code: SOLID
Clean code: SOLID
 
Clean code: SOLID (iOS)
Clean code: SOLID (iOS)Clean code: SOLID (iOS)
Clean code: SOLID (iOS)
 
Is your code solid
Is your code solidIs your code solid
Is your code solid
 
S.O.L.I.D. principles of software development
S.O.L.I.D. principles of software developmentS.O.L.I.D. principles of software development
S.O.L.I.D. principles of software development
 
Principle of OOD
Principle of OODPrinciple of OOD
Principle of OOD
 

Recently uploaded

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
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
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.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
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 

SOLID Principles Part 3

  • 1. SOLID Principles - III DIP – Dependency Inversion Principle Maulik Soni
  • 2. Dependency Inversion Principle  High-level modules should not depend on low-level modules  Both should depend on abstractions  Abstractions should not depend on details  Details should depend on abstractions Maulik Soni
  • 3. Dependency Inversion Principle DIP is at the very heart of framework design Maulik Soni
  • 4. How To Spot DIP Violation ?  Direct Instantiation  new SomeObject();  Static Methods  ServiceLocator.getObject(); Maulik Soni
  • 5. Is DIP Violated Here ? Maulik Soni
  • 8. Demo  Demo of DIP and Dependency Injection using Unity Maulik Soni
  • 9. Summary  Depend on abstractions  No variable should hold a reference to a concrete class  No class should derive from a concrete class  No method should override an implemented method of any of its base classes  Heuristic is typically violated at least once  Somebody has to create the instances of the concrete classes  No reason to strictly follow this heuristic for classes that are concrete but non-volatile Maulik Soni
  • 10. End of Presentation Maulik Soni  End of Introduction to SOLID Principles  S = Single Responsibility  O = Open / Closed  L = Liskov Substitution  I = Interface Segregation  D = Dependency Inversion

Editor's Notes

  1. Framework – where making changes are easy, each piece is extensible, every dependency is replacible