Inversion Of Control & Dependency Injection Break Apart The Dependencies Oren Eini Senior Developer We! Consulting Group

Slides:



Advertisements
Similar presentations
Copyright © 2005 Finetix LLC All Rights Reserved 0 Spring Framework Developer Session Chris Donnan & Solomon Duskis The Peer Frameworks Series -.Net and.
Advertisements

Real world TDD + Dependency Injection Rob Fonseca-Ensor Datacom Systems.
Spring, Hibernate and Web Services 13 th September 2014.
Copyright © 2008 Accenture All Rights Reserved. Accenture, its logo, and High Performance Delivered are trademarks of Accenture. Andrew Stone Common Security.
Enterprise development reference architecture (EDRA) -Deepti Seelamsetti.
CSLA Presenter Sergey Barskiy, senior consultant at Magenic Technologies your questions Send an in order.
Confidential - Property of infiNET Solutions. Architecting and Designing Scalable, Multitier Systems in J2EE infiNET Solutions David R. King – Chief Technology.
Software Factory Assembling Applications with Models, Patterns, Frameworks and Tools Anna Liu Senior Architect Advisor Microsoft Australia.
Spring.Net Steinar Dragsnes steinar.dragsnes at viz.no.
© 2005, Cornell University. Rapid Application Development using the Kuali Architecture (Struts, Spring and OJB) A Case Study Bryan Hutchinson
PRESENTED BY SANGEETA MEHTA EECS810 UNIVERSITY OF KANSAS OCTOBER 2008 Design Patterns.
T HE B ASICS O F S OFTWARE A RCHITECTURE F OR.NET D EVELOPERS Dan Douglas | Senior Software Developer/ Architect Blog:
Design Patterns academy.zariba.com 1. Lecture Content 1.What are Design Patterns? 2.Creational 3.Structural 4.Behavioral 5.Architectural 6.Design Patterns.
enterprise S.O.A. SOA What? why R U here? mandated to build company portal understand how to fit GIS into a portal technology enthusiast.
Intro to Spring CJUG - January What is Spring? “The Spring framework provides central transaction control of various objects.” This means that any.
Web application architecture
Dependency Injection and Model-View-Controller. Overview Inversion of Control Model-View-Controller.
Spring Overview, Application demo -Midhila Paineni 09/23/2011 Spring Overview, Application demo9/8/20151.
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.
ASP.NET Web API Udaiappa Ramachandran NHDN-Nashua.NET/Cloud Computing UG Lead Blog:
Todd Snyder Development Team Lead Infragistics Experience Design Group.
Spring core v3.x Prepared by: Nhan Le. History v3.0 Spring Expression Language Java based bean metadata v3.1 Cache Abstraction Bean Definition Profile.
PicoContainer Presented by: Jim O’Hara Ed Kausmeyer Jingming Zhang.
Anti Orgla, Nortal AS Spring Framework
SAMANVITHA RAMAYANAM 18 TH FEBRUARY 2010 CPE 691 LAYERED APPLICATION.
1 Another group of Patterns Architectural Patterns.
Copyright © 2005 Finetix LLC All Rights Reserved 0 SpringFramework.Net Developer Session Chris Donnan The Peer Frameworks Series -.Net and Java.
Abstract Factory Design Pattern making abstract things.
Sander Hoogendoorn Principal Technology Officer Capgemini The Netherlands SESSION CODE: ARC303.
Castle Manoj Waikar Pune, India.. Introduction Castle aspires to simplify the development of enterprise and web applications. It offers a set of tools.
Alcatel-Lucent CDC Workshop, Coaching & Knowledge Transfer Architecture.
Design Patterns CSCI 5801: Software Engineering. Design Patterns.
Architectural pattern: Interceptor Source: POSA II pp 109 – 140POSA II Environment: developing frameworks that can be extended transparently Recurring.
Software Design Patterns (1) Introduction. patterns do … & do not … Patterns do... provide common vocabulary provide “shorthand” for effectively communicating.
Refactoring for Testability (or how I learned to stop worrying and love failing tests) Presented by Aaron Evans.
Using Mock Objects with Test Driven Development Justin Kohlhepp
METS Dissemination METS Opening Day Corey Keith
Service Oriented Architecture CCT355H5 Professor Michael Jones Suezan Makkar.
Unit 4 Object-Oriented Design Patterns NameStudent Number CAI XIANGHT082182A KYAW THU LINHT082238Y LI PENGFEIHT082220L NAUNG NAUNG LATTHT082195L PLATHOTTAM.
Design Patterns CSIS 3701: Advanced Object Oriented Programming.
Alternative Architectures: Inversion of Control Mike Hadlow mikehadlow.blogspot.com.
Design Patterns -- Omkar. Introduction  When do we use design patterns  Uses of design patterns  Classification of design patterns  Creational design.
Java EE Patterns Dan Bugariu.  What is Java EE ?  What is a Pattern ?
Design for testability as a way to good coding Simone Chiaretta Architect, Council of the EU December 9 th,
Design Reuse Earlier we have covered the re-usable Architectural Styles as design patterns for High-Level Design. At mid-level and low-level, design patterns.
Dependency Injection Frameworks Technion – Institute of Technology Author: Assaf Israel - Technion 2013 ©
Design Patterns in Context ©SoftMoore ConsultingSlide 1.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Overview of the Spring Framework Introducing.
Jean-Claude Trachsel Senior Consultant, Trivadis AG The good news.
L’origine dei mali: le dipendenze tra componenti Stefano Leli 14° Workshop DotNetMarche Venerdì 16 aprile
Modern Development Technologies in SharePoint SHAREPOINT SATURDAY OMAHA APRIL, 2016.
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.
Enterprise Library 3.0 Memi Lavi Solution Architect Microsoft Consulting Services Guy Burstein Senior Consultant Advantech – Microsoft Division.
Leveraging ColdSpring to build a robust Flex applications Chris Scott, Cynergy Systems.
Facade Pattern Jim Fawcett CSE776 – Design Patterns Summer 2010
Designing software applications
Mark Seemann - Dependency Injection in .NET
Managed Extensibility Framework
Facade Pattern Jim Fawcett CSE776 – Design Patterns Summer 2010
Intro to Spring CJUG - January 2013.
SAMANVITHA RAMAYANAM 18TH FEBRUARY 2010 CPE 691
Developing and testing enterprise Java applications
Leveraging ColdSpring To Make Better Applications
Chapter 8, Design Patterns Introduction
European conference.
Dependency Inversion principle
Dependency Injection Mechanism
Presentation transcript:

Inversion Of Control & Dependency Injection Break Apart The Dependencies Oren Eini Senior Developer We! Consulting Group

Who wants to try to move that?

What can we do about it?

Who am I and what I do? Senior Developer at We! Mostly dealing with complex business applications 100% of current projects using IoC Blogger - ~95,000 visits / month – Object Relational Mapping – Inversion Of Control – Model View Controller architectures for the web – Various Development topics

What it is – Architecture? Decreased Coupling Greater Flexibility Separation of Concerns Interface Driven Design Dependency Management (via Dependency Injection or Service Lookup) Component Oriented Programming

What is it – Technology? (Very) smart factory Automatic resolving and injection of dependencies

A bit about terminology Container Service / Component Inversion of Control Dependency Injection

What is the problem we are trying to solve? To understand the solution, we need to understand what the problem is…

LET US HAVE A PIZZA…

The Pizza Process

Coupled Pizza Place

Client Code Customer customer = new Customer("Fred"); CoupledPizzaPlace pizzaPlace = new CoupledPizzaPlace(); pizzaPlace.MakeOrder(customer,3);

Coupled Pizza Place Clerk knows about cook Deliveries service knows about clerk Cook knows about clerk Clerk knows about cook Deliveries service knows about clerk Cook knows about clerk

Coupled Pizza Place

Decoupled Pizza Place Just put some interfaces…

Decoupled Client Code Oven oven = new Oven(); MakePizzaCook takePizzaFromOvenCook = new MakePizzaCook(oven); OrdersClerk ordersClerk = new OrdersClerk(takePizzaFromOvenCook); MakeDevliveriesService makeDevliveriesService = new MakeDevliveriesService(ordersClerk); TakePizzaFromOvenCook makePizzaCook = new TakePizzaFromOvenCook(oven, ordersClerk); DecoupledPizzaPlace pizzaPlace = new DecoupledPizzaPlace(takePizzaFromOvenCook, ordersClerk, makeDevliveriesService, makePizzaCook); Customer customer = new Customer("Fred"); pizzaPlace.MakeOrder(customer,3);

Into Factory Method DecoupledPizzaPlace pizzaPlace = DecoupledPizzaPlace.Create(); Customer customer = new Customer("Fred"); pizzaPlace.MakeOrder(customer, 3);

Decoupled Pizza Place

IoC Pizza Place

IoC Client Code IoC.Initialize( new RhinoContainer("Pizza.boo")); Customer customer = new Customer("Fred"); IoCPizzaPlace pizzaPlace = IoC.Resolve (); pizzaPlace.MakeOrder(customer, 3); pizzaPlace.DoWork(); Configuration (later)

Configuring IoC: Using DSL Component("sara", IClerk, OrdersClerk) Component("nissim", ICook, MakePizzaCook) Component("moshe", IMakeDeliveries, MakeDeliveriesService) Component("nir", ICook, TakePizzaFromOvenCook) Component("oven", Oven) Component("pizza", IoCPizzaPlace, Yes, you can do it with XML as well…

IoC.Resolve (); IClerk IMakeDe liveries ICook IClerk Oven Second Cook

Inversion Of Control Container All the services in the application are registered in the container. Single point of access to all the services in the application. Automatically resolves all the dependencies of services registered with the container. Neither the client nor the service are tied to the dependencies.

Benefits of IoC Dependencies are managed for you. Highly focused objects (single responsibility, separation of concerns). Testability. Objects are not coupled directly to environment resources or other unintended implementations

Why not do it myself?

Flexibility… Component("sara", IClerk, OrdersClerk) Component("nissim", ICook, MakePizzaCook) Component("moshe", IMakeDeliveries, MakeDeliveriesService) Component("nir", ICook, TakePizzaFromOvenCook) Component("oven", Oven) Component("pizza", IoCPizzaPlace, TempClerk );

And in the real world… Changing the payment service: PayPal  Credit Card Changing the delivery service: UPS  FedEx Changing a database Replacing validation rules

Implementations In.Net Castle Windsor Spring.Net Structure Map Object Builder

ADVANCE STUFF: EXPLODING HEADS ZONE

Generic Services Usage: //from database IoC.Resolve >.Get(1337); //from active directory IoC.Resolve >.Get(42);

Configuration Component("users_repository", IRepository of User, ActiveDirectoryRepository) Component("database_repository", IRepository, NHibernateRepository)

Generic Specialization Usage: IoC.Resolve >.Get(5); IoC.Resolve >.Get(15);

A word about decorators Client code… Security Decorator Logging Decorator Caching Decorator Real Reposistory

Configuration Component("logging_users_repository", IRepository of User, LoggingDecorator of User, Component("logging_ database _repository", IRepository, LoggingDecorator, Component("users_repository", IRepository of User, ActiveDirectoryRepository) Component("database_repository", IRepository, NHibernateRepository)

Other uses of Inversion of Control Containers Manage lifetime of services (singleton, transient, per request, etc). Aspect Oriented Programming Decorators

Pros Simpler Architecture Reduced cost of change Encourage best practices Interface driven design and component oriented programming Less work More smarts from the framework

Cons Need to learn Higher level of abstraction Misuse of architecture

Resources Inversion of Control Containers and the Dependency Injection pattern – Martin Fowler Inversion of Control Containers and the Dependency Injection pattern The Dependency Injection Principal - Robert C. Martin The Dependency Injection Principal Inversion of Control and Dependency Injection: Working with Windsor Container – Oren Eini Inversion of Control and Dependency Injection: Working with Windsor Container

Come to meet me at the Architecture & Developers Panels or visit my blog: