Dependency Inversion Principle Jon McBee Principal Software Engineer Ultratech CNT.

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
St Louis Day of.NET 2011 Refactoring to a SOLID Foundation Steve Bohlen Senior Software Engineer SpringSource/VMware Blog:
Stability and Volatility is Software Design H. Rahnama Tutorial in software engineering.
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
Software Requirements Engineering
SOLID Object Oriented Design Craig Berntson
Developed by Reneta Barneva, SUNY Fredonia Component Level Design.
Structure of a web application1 Dr Jim Briggs. MVC Structure of a web application2.
BY RAJESWARI S SOFTWARE TESTING. INTRODUCTION Software testing is the process of testing the software product. Effective software testing will contribute.
6 Systems Analysis and Design in a Changing World, Fourth Edition.
The chapter will address the following questions:
Presenter - Donn Felker.  Senior Consultant for Microsoft Gold Certified Partner- Statêra.  8 years of experience in developing and architecting enterprise.
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”.
COMP 410 & Sky.NET May 2 nd, What is COMP 410? Forming an independent company The customer The planning Learning teamwork.
DEFECTS By K.KARTHIKE. WHAT IS DEFECTS? Software bug, a failure of computer software to meet requirements Software bug The term defect and its relationship.
Company Confidential – Do Not Duplicate 2 Copyright 2008 McLane Advanced Technologies, LLC S.O.L.I.D. Software Development Achieving Object Oriented Principles,
Software Engineering INTRODUCTION TO SOFTWARE ENGINEERING.
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.
Design Principles iwongu at gmail dot com.
The benefits of SOLID in software development Ruben Agudo Santos (GS-AIS-HR)
Chapter 12 Computer Programming. 12 Chapter 12: Computer Programming 2 Chapter Contents  Section A: Programming Basics  Section B: Procedural Programming.
 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
Special Relativity Study Questions PHYS 252 Dr. Varriano.
Software Design Patterns Curtsy: Fahad Hassan (TxLabs)
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,
CSE 303 – Software Design and Architecture
CSI 1340 Introduction to Computer Science II Chapter 1 Software Engineering Principles.
CHAPTER 3 MODELING COMPONENT-LEVEL 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.
Troops and Flags Graduate Group #1 Introduction to Game Design and Development 12/10/2007.
SOLID Design Principles
Session 33 More on SOLID Steve Chenoweth Office: Moench Room F220 Phone: (812) Chandan Rupakheti Office: Moench.
6 Systems Analysis and Design in a Changing World, Fourth Edition.
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.
CS223: Software Engineering Lecture 19: Unit Testing.
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.
Mantas Radzevičius ifm-2/2
Course information Old exam Resit Report Result and walkthrough
Dependency Inversion Principle
Coupling and Cohesion Rajni Bhalla.
Structure of a web application
Designing software applications
Software Architecture & Difference from Design
Copyright © by Curt Hill
lecture 08, OO Design Principle
11/29/2018 © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks.
Software Engineering Lecture #9.
Design Tips.
Structure Charts Agenda: What are Structure Charts
The SOLID Principles.
A (partial) blueprint for dealing with change
Principles of Object-Oriented Design

Dependency Inversion principle
Some principles for object oriented design
Architectural Mismatch: Why reuse is so hard?
Presentation transcript:

Dependency Inversion Principle Jon McBee Principal Software Engineer Ultratech CNT

Dependency Inversion Principle Depend upon abstract entities, not concrete entities

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. Both should depend on abstractions. Message Broker Message Transport QueueNotifierAF Message

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. Details should depend on abstractions. Message Broker Message Transport QueueNotifierAF MessageEvent Adding an Event Message Transport type should not Cause the Message Transport interface to change

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

Dependency Inversion Principle

Two Types of Dependency 1.Runtime dependency exists whenever two modules interact at runtime 2.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 Mass Calculate Event Horizon

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

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

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

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 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? EmployeeiDataWriter + Write XML + Write DB + Write

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

Demo: DIP in the Wild

Questions?