Mark Seemann - Dependency Injection in .NET

Slides:



Advertisements
Similar presentations
Spring, Hibernate and Web Services 13 th September 2014.
Advertisements

PRESENTED BY SANGEETA MEHTA EECS810 UNIVERSITY OF KANSAS OCTOBER 2008 Design Patterns.
Intro to Spring CJUG - January What is Spring? “The Spring framework provides central transaction control of various objects.” This means that any.
Dependency Injection and Model-View-Controller. Overview Inversion of Control Model-View-Controller.
Introduction to the Spring Framework By: Nigusse A. Duguma Kansas State university Department of Computer Science Nov 20, 2007.
Presenter - Donn Felker.  Senior Consultant for Microsoft Gold Certified Partner- Statêra.  8 years of experience in developing and architecting enterprise.
Building SOLID Software with Dependency Injection Jeremy Rosenberg.
Todd Snyder Development Team Lead Infragistics Experience Design Group.
Case Studies on Design Patterns Design Refinements Examples.
Creational Patterns (1) CS350, SE310, Fall, 2010.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
SAMANVITHA RAMAYANAM 18 TH FEBRUARY 2010 CPE 691 LAYERED APPLICATION.
Patterns in programming 1. What are patterns? “A design pattern is a general, reusable solution to a commonly occurring problem in software. A design.
Spring Framework. Spring Overview Spring is an open source layered Java/J2EE application framework Created by Rod Johnson Based on book “Expert one-on-one.
Sander Hoogendoorn Principal Technology Officer Capgemini The Netherlands SESSION CODE: ARC303.
Inversion Of Control & Dependency Injection Break Apart The Dependencies Oren Eini Senior Developer We! Consulting Group
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns IX Interpreter, Mediator, Template Method recap.
SWE © Solomon Seifu ELABORATION. SWE © Solomon Seifu Lesson 12-5 Software Engineering Design Goals.
Refactoring for Testability (or how I learned to stop worrying and love failing tests) Presented by Aaron Evans.
CSE 403, Spring 2008, Alverson Software Design “There are two ways of constructing a software design: one way is to make it so simple that there are obviously.
Design Principle & Patterns by A.Surasit Samaisut Copyrights : All Rights Reserved.
Alternative Architectures: Inversion of Control Mike Hadlow mikehadlow.blogspot.com.
Incremental Design Why incremental design? Goal of incremental design Tools for incremental design  UML diagrams  Design principles  Design patterns.
Design for testability as a way to good coding Simone Chiaretta Architect, Council of the EU December 9 th,
Five design principles
Review of Parnas’ Criteria for Decomposing Systems into Modules Zheng Wang, Yuan Zhang Michigan State University 04/19/2002.
SOLID Design Principles
Dependency injection Marko Tošić
Virtual techdays INDIA │ 9-11 February 2011 SESSION TITLE Kamala Rajan S │ Technical Manager, Marlabs.
1 Good Object-Oriented Design Dr. Radu Marinescu Lecture 4 Introduction to Design Patterns.
Jean-Claude Trachsel Senior Consultant, Trivadis AG The good news.
Dependency Injection with Guice Technion – Institute of Technology Author: Gal Lalouche - Technion 2016 ©
Microsoft Advertising 16:9 Template Light Use the slides below to start the design of your presentation. Additional slides layouts (title slides, tile.
Vladan Strigo CTO NETmedia ASP.NET Web Api Tips & Tricks.
Understanding Dependency Injection… and those pesky containers Miguel A. Castro Architect -
Introduction to Inversion Of Control (IOC). IOC Definition (based on Wikipedia)  Consider the way in which an object obtains references to its dependencies.
350 parts. i-bank functional structure ▪technical modules – authentication – auditing – user profile – OTP functionality – notifications – push.
Patterns in programming
Introduction to .NET Florin Olariu
Software Architecture & Difference from Design
Chapter 5:Design Patterns
ASP.NET MVC Introduction
Low Budget Productions, LLC
CSE687 - Object Oriented Design class notes Survey of the C++ Programming Language Jim Fawcett Spring 2004.
Build Windows 10 UWP MVVM Apps with Prism
Dependency Injection Andres Käver, IT College 2016/2017 Spring.
Did your feature got in, out or planned?
Managed Extensibility Framework
How to be a Good Developer
Magento Technical Guidelines Eugene Shakhsuvarov, Software Magento
The Object-Oriented Thought Process Chapter 08
Jessica Betts, Sophia Pandey, & Ryan Amundson
Software Re-engineering - Theoretical and Practical Approaches
Microsoft Build /15/2018 6:28 AM © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY,
Present by Andie Saizan, MCP
lecture 08, OO Design Principle
Titel Dependency Injection.
Object Oriented Practices
An Introduction to Software Architecture
SAMANVITHA RAMAYANAM 18TH FEBRUARY 2010 CPE 691
CS 350 – Software Design Principles and Strategies – Chapter 14
Informatics 122 Software Design II
European conference.
Extending Interface Based Design
Chapter 8 - Design Strategies
#01# ASP.NET Core Overview Design by: TEDU Trainer: Bach Ngoc Toan
Dependency Injection Mechanism
Concepts in ASP.NET Core App
Jim Fawcett CSE687 – Object Oriented Design Spring 2015
04 | Understanding Frameworks
Presentation transcript:

Mark Seemann - Dependency Injection in .NET

DI Definition Dependency Injection is a set of software design principles and patterns that enable us to develop loosely coupled code. * DI Container is not required. * Inversion of Control is a wider term than Dependency Injection.

Benefits of DI Late binding Services can be swapped with other services. Extensibility & Maintainability Code can be extended and reused in ways not explicitly planned for. Classes with clearly defined responsibilities are easier to maintain. Parallel development Code can be developed in parallel. Testability Classes can be unit tested.

Stable & Volatile Dependencies Stable dependency satisfies all these rules: The class or module already exists. You expect that new versions won’t contain breaking changes. The types in question contain deterministic algorithms. You never expect to have to replace the class or module with another. If dependency does not satisfy one or several points from above list, then it’s a volatile dependency that should be injected.

Configuring DI Containers

Configuration ways: pros & cons

Composition Root

Register Resolve Release

DI Patterns Constructor Injection Property Injection Method Injection Ambient Injection

Constructor Injection

Property Injection

Property Injection usage Unity DependencyAttribute

Method Injection

Ambient Context

Choosing DI pattern

DI anti-pattern: Control Freak

DI anti-pattern: Bastard Injection

DI anti-pattern: Constrained Construction *Is only applicable for late binding.

DI anti-pattern: Service Locator

DI refactorings (challenges) Mapping runtime value to ABSTRACTIONS Route algorithm example. Use Abstract Factory. Working with short-lived DEPENDENCIES Connections, clients, etc. Use Abstract Factory. Resolving cyclic DEPENDENCIES Break dependency through Property Injection.

Object Composition Console application ASP.NET MVC application WCF service WPF application ASP.NET application PowerShell cmdlets

Lifestyle catalog

Interception

Cross-Cutting Concerns

DI Container Feature comparison