Dependency Inversion Principle

Slides:



Advertisements
Similar presentations
Automated Evaluation of Runtime Object States Against Model-Level States for State-Based Test Execution Frank(Weifeng) Xu, Gannon University Dianxiang.
Advertisements

Design Principles & Patterns
COMPSCI 105 S Principles of Computer Science 12 Abstract Data Type.
St Louis Day of.NET 2011 Refactoring to a SOLID Foundation Steve Bohlen Senior Software Engineer SpringSource/VMware Blog:
General OO Concepts and Principles CSE301 University of Sunderland Harry R. Erwin, PhD.
Lecture 9 Improving Software Design CSC301-Winter 2011 – University of Toronto – Department of Computer Science Hesam C. Esfahani
SOLID Object Oriented Design Craig Berntson
Software Engineering Module 1 -Components Teaching unit 3 – Advanced development Ernesto Damiani Free University of Bozen - Bolzano Lesson 2 – Components.
Developed by Reneta Barneva, SUNY Fredonia Component Level Design.
The chapter will address the following questions:
Dependency Injection and Model-View-Controller. Overview Inversion of Control Model-View-Controller.
Presenter - Donn Felker.  Senior Consultant for Microsoft Gold Certified Partner- Statêra.  8 years of experience in developing and architecting enterprise.
Build Robust Web Apps in the Real WakeUpAndCode.com.
CLASS DESIGN PRINCIPLES Lecture 2. The quality of the architecture What is a good design? It is the design that at least does not have signs of “bad”.
Design Dan Fleck CS 421 George Mason University. What is the design phase? Analysis phase describes what the system should do Analysis has provided a.
Company Confidential – Do Not Duplicate 2 Copyright 2008 McLane Advanced Technologies, LLC S.O.L.I.D. Software Development Achieving Object Oriented Principles,
Tech Talk Go4 Factory Patterns Presented By: Matt Wilson.
© 2004 Capgemini - All rights reserved SOLID - OO DESIGN PRINCIPLES Andreas Enbohm, Capgemini.
Introduction to SOLID Principles. Background Dependency Inversion Principle Single Responsibility Principle Open/Closed Principle Liskov Substitution.
S.O.L.I.D. Software Development 12 January 2010 (Martin Verboon, Patrick Kalkman, Stan Verdiesen)
SWE © Solomon Seifu ELABORATION. SWE © Solomon Seifu Lesson 12-5 Software Engineering Design Goals.
Coupling Cohesion Chandan R. Rupakheti Steve Chenoweth (Chapter 18)
 What is SOLID  The S in SOLID  The O in SOLID  The L in SOLID  The I in SOLID  The D in SOLID  Questions.
Software Design Principles
Via Self Service on the web. Vacation and Sick Time Reporting For entry of the employee’s vacation and sick time: The employee will log on to self service.
1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 11a: Component-Level Design Software Engineering: A Practitioner’s Approach, 6/e Chapter.
Design for testability as a way to good coding Simone Chiaretta Architect, Council of the EU December 9 th,
Five design principles
Build Robust Web Apps in the Real WakeUpAndCode.com.
Service Oriented Architecture + SOAP -Robin John.
Ken Casada Developer Evangelist Microsoft Switzerland
CHAPTER 3 MODELING COMPONENT-LEVEL DESIGN.
Principles of Object Oriented Design
PRINCIPLES OF OBJECT ORIENTED DESIGN S.O.L.I.D. S.O.L.I.D Principles What is SOLID?  Acrostic of 5 Principles:  The Single Responsibility Principle.
Welcome to Employee Access ADP’s HR/Benefits Solution.
Steps to integrate XML How does XML processing work? Simple uses of passive DOM objects Adding behaviour to information A converter and translator subsystem.
SOLID Design Principles
ANU comp2110 Software Design lecture 10 COMP2110 Software Design in 2004 lecture 10 Software Architecture 2 of 2 design lecture 5 of 6 Goal of this small.
Dependency Inversion Principle Jon McBee Principal Software Engineer Ultratech CNT.
Session 33 More on SOLID Steve Chenoweth Office: Moench Room F220 Phone: (812) Chandan Rupakheti Office: Moench.
Dependency Inversion By Steve Faurie. Dependency Inversion Described in Agile Principles, Patterns and Practices in C# by Robert C. Martin.
Workflow Service Host Persistence (Instances) Persistence (Instances) Monitoring Activity Library Receive Send... Management Endpoint Persistence Behavior.
Architectural Mismatch: Why reuse is so hard? Garlan, Allen, Ockerbloom; 1994.
Liskov Substitution Principle Jon McBee CLA, CLED, CTD, CPI, LabVIEW Champion.
Microsoft Advertising 16:9 Template Light Use the slides below to start the design of your presentation. Additional slides layouts (title slides, tile.
Beginning Software Craftsmanship Brendan Enrick Steve Smith
Principles of Package Design COMPOSE AT A HIGHER LEVEL OF ABSTRACTION.
I Copyright © 2004, Oracle. All rights reserved. Introduction.
Interface Segregation / Dependency Inversion
Course information Old exam Resit Report Result and walkthrough
Coupling and Cohesion Rajni Bhalla.
Software Design Principles
Designing software applications
Software Architecture & Difference from Design
The Object-Oriented Thought Process Chapter 1
Copyright © by Curt Hill
HR Portal Team Dr. Ashraf Armoush Supervisor Ala’eddeen Awwad
Chapter 9 Moving to Design Part 1.
Software Design Principles
11/29/2018 © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks.
Design Tips.
Service Oriented Architecture + SOAP
Review CSE116 2/21/2019 B.Ramamurthy.
The SOLID Principles.
A (partial) blueprint for dealing with change
Principles of Object-Oriented Design
European conference.

Dependency Inversion principle
Architectural Mismatch: Why reuse is so hard?
Presentation transcript:

Dependency Inversion Principle Jon McBee President Composed Systems

Dependency Inversion Principle Depend upon abstract entities, not concrete entities

A. High-level modules should not depend on low-level modules A. High-level modules should not depend on low-level modules. Both should depend on abstractions. B. Abstractions should not depend on details. Details should depend on abstractions.

A. High-level modules should not depend on low-level modules A. High-level modules should not depend on low-level modules. Both should depend on abstractions. Message Broker Message Transport Notifier Queue AF Message

B. Abstractions should not depend on details B. Abstractions should not depend on details. Details should depend on abstractions.

By passing dependencies to classes as abstractions, you remove the need to program dependency specific By giving a craftsman a Craftsman Bolt On® base, you remove the need for the craftsman to lug around a bag of tools

B. Abstractions should not depend on details B. Abstractions should not depend on details. Details should depend on abstractions. Message Broker Adding an Event Message Transport type should not Cause the Message Transport interface to change Message Transport Notifier Queue AF Message Event

B. Abstractions should not depend on details B. Abstractions should not depend on details. Details should depend on abstractions. Message Broker Message Transport Event

Dependency Inversion Principle

Two Types of Dependency Runtime dependency exists whenever two modules interact at runtime Source code dependency exists when a method defined by one module is called by another module

Runtime Dependency Tree Black Hole Travelers Guide Calculate Time Dilation Calculate Tidal Forces Calculate Evaporation Rate Calculate Event Horizon Calculate Mass

Source Code Dependency Tree Black Hole Travelers Guide Calculate Time Dilation Calculate Tidal Forces Calculate Evaporation Rate Calculate Event Horizon Calculate Mass

Calculate Tidal Forces Break the Source Code Dependency Calculate Tidal Forces Calculate Mass + Calculate Mass

Break the Source Code Dependency Calculate Tidal Forces Abstract Calculate Mass + Calculate Mass Calculate Mass + Calculate Mass http://www.labviewcraftsmen.com/blog/fun-with-the-actor-framework-low-coupled-messaging

Dependency Inversion Source Code Dependency Tree Runtime Dependency Tree Calculate Tidal Forces Abstract Calculate Mass Calculate Tidal Forces “Dependencies are inverted whenever the source code dependencies oppose the direction of the flow of control” -Bob Martin + Calculate Mass Calculate Mass Calculate Mass + Calculate Mass + Calculate Mass

Discussion Question Q: Assume that we are writing an application for our HR department that tracks employees and that we have an Employee class that needs to be able to save data to both XML and to a database. How should we give the Employee class this ability? P1: Should we give the Employee class ToXML.vi and ToDB.vi methods? P2: Should we give the Employee class a Write.vi method that takes as an input a flag for either writing to XML or to DB using an XML or DB object respectively?

Discussion Question This would violate SRP! This would violate OCP! Q: Assume that we have are writing an application for our HR department that tracks employees and that we have an Employee class that needs to be able to save data to XML and to a database. How should we give the Employee class this ability? P1: Should we give the Employee class ToXML.vi and ToDB.vi methods? This would violate SRP! P2: Should we give the Employee class a Write.vi method that takes as an input a flag for either writing to XML or to DB using an XML or DB object respectively? This would violate OCP!

Discussion Question Q: Assume that we have are writing an application for our HR department that tracks employees and that we have an Employee class that needs to be able to save data to XML and to a database. How should we give the Employee class this ability? Employee iDataWriter + Write XML DB + Write + Write

Dependency Injection Dependency Injection is NOT Dependency Inversion! You must first invert your dependencies to properly apply dependency injection Dependency Injection Dependency Inversion

Demo: DIP in the Wild

Questions?