SlideShare une entreprise Scribd logo
1  sur  49
Manage software dependencies with IoC and AOP Stefano Leli 14° Workshop DotNetMarche Friday 16 th  April 2010 @sleli [email_address]
[object Object],[object Object],[object Object],[object Object],[object Object],Agenda
[object Object]
Dependencies public RequestService() { ClassB b = new ClassB() b.DoService(); } dependent +DoService() ClassA +RequestService() ClassB
Layer Dependencies ,[object Object],[object Object],Presentation Layer Business Layer Data Access Layer Depends  on DB Depends  on Depends  on
Why dependencies are evil? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object]
Copier Example Copier + PerformCopy() Keyboard + ReadFromKB(c : char ) Video + WriteToVideo ()  : char
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Copier Example class Keyboard { public int ReadFromKeyboard() {  return Console.ReadKey(true).KeyChar; } } class Video { public void WriteToVideo(int chr) { Console.Write((char)chr); } }
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Copier Example class Keyboard { public int ReadFromKeyboard() {  return Console.ReadKey(true).KeyChar; } } class Video { public void WriteToVideo(int chr) { Console.Write((char)chr); } } Problem
[object Object]
Copier Example <<create>> <<create>> Concrete class should depend on abstraction Robert Martin IWriter IReader Copier + PerformCopy() Keyboard + Read(c : char ) Video + Write ()  : char
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Copier Example class Keyboard  : IReader { public int  Read () {  return Console.ReadKey(true).KeyChar; } } class Video  : IWriter { public void  Write (int chr) { Console.Write((char)chr); } }
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Copier Example class Keyboard  : IReader { public int  Read () {  return Console.ReadKey(true).KeyChar; } } class Video  : IWriter { public void  Write (int chr) { Console.Write((char)chr); } } Problem Dependencies resolution is still here!!!
[object Object],[object Object]
<<create>> Using a Factory <<create>> Copier + Copier(r : IReader, w : IWriter) + PerformCopy() IWriter IReader Keyboard + Read(c : char ) Video + Write ()  : char ReaderFactory + GetInstance() : IReader WriterFactory + GetInstance() : IWriter
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Using a Factory class ReaderFactory { public static IReader GetInstance() { return new Keyboard(); } } class WriterFactory { public static IWriter GetInstance() { return new Video(); } }
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Using a Factory class ReaderFactory { public static IReader GetInstance() { return new Keyboard(); } } class WriterFactory { public static IWriter GetInstance() { return new Video(); } } We have just moved the problem!!! Problem
Service Locator << create >> <<create>> Copier + PerformCopy() ServiceLocator +Lookup() : Object +RegisterService(o : Object) _instance : ServiceLocator … IWriter IReader Keyboard + Read(c : char ) Video + Write ()  : char
Service Locator << create >> <<create>> Copier + PerformCopy() ServiceLocator +Lookup() : Object +RegisterService(o : Object) _instance : ServiceLocator … IWriter IReader Keyboard + Read(c : char ) Video + Write ()  : char
Service Locator class ServiceLocator { /* Singleton instance */ private static ServiceLocator _instance;  public static void Load(ServiceLocator arg) { _instance = arg; } /* Storing and Retrieve services */ private Dictionary<string, Object> _services = new Dictionary<string, Object>(); public Object RegisterService(String key) { return _instance._services[key]; } public static void Lookup(String key, Object service) { _services.Add(key, service); } }
Service Locator ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],/*  Configure Service Locator method */ private void configureLocator() { ServiceLocator locator = new ServiceLocator();  locator.LoadService(&quot;reader&quot;, new Keyboard()); locator.LoadService(&quot;writer&quot;, new Video()); ServiceLocator.Load(locator); }
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Service Locator
[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],What is IoC?
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],What is Dependency Injection?
IoC Container Copier + Copier(r : IReader, w : IWriter) + PerformCopy() IWriter IReader Keyboard + Read(c : char ) Video + Write ()  : char
<< create >> <<create>> IoC Container <<create>> Copier + Copier(r : IReader, w : IWriter) + PerformCopy() XML Config IWriter IReader Keyboard + Read(c : char ) Video + Write ()  : char IoCContainer …
DI: Constructor Injection ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],To prefer in case of Mandatory Dependencies
DI: Setter Injection ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],To prefer in case of Optional Dependencies
DI: Interface Injection ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],interface IReaderInject { void injectReader(IReader reader);  } interface IWriterInject { void injectWriter(IWriter reader);  } Quite Never Used
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],DI: Consideration
[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],What is AOP?
Separation of Concern Searching Booking Payment
Separation of Concern ,[object Object],[object Object],[object Object],[object Object],Booking Payment Searching OOP Searching Booking Payment
Crosscutting Concern ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Booking Security Logging Payment Security Logging Searching Security Logging OOP Crosscutting  Concerns Searching Booking Payment
Crosscutting Concern Booking Payment Searching Security Logging AOP Booking Security Logging Payment Security Logging Searching Security Logging OOP Crosscutting Concerns Searching Booking Payment
How it works… Object_B Object_A Object Oriented Flow
How it works… Aspect Object_B Object_A advice Object Oriented Flow Aspect Oriented Flow pointcut = method_B Target Object = Object_B jointpoint = method invocation
How it works… ,[object Object],[object Object],[object Object],Aspect Object_B Object_A advice Object Oriented Flow Aspect Oriented Flow pointcut = method_B Target Object = Object_B jointpoint = method invocation
How it works… ,[object Object],[object Object],Aspect Object_B Object_A advice Object Oriented Flow Aspect Oriented Flow pointcut = method_B Target Object = Object_B jointpoint = method invocation
How it works… ,[object Object],[object Object],Aspect Object_B Object_A advice Object Oriented Flow Aspect Oriented Flow pointcut = method_B Target Object = Object_B jointpoint = method invocation
How it works… ,[object Object],[object Object],[object Object],Aspect Object_B Object_A advice Object Oriented Flow Aspect Oriented Flow pointcut = method_B Target Object = Object_B jointpoint = method invocation
How it works… ,[object Object],[object Object],[object Object],Aspect Object_B Object_A advice Object Oriented Flow Aspect Oriented Flow pointcut = method_B Target Object = Object_B jointpoint = method invocation
[object Object],[object Object],[object Object],…  behind the scenes Aspect Object_B Object_A advice Object Oriented Flow Aspect Oriented Flow pointcut = method_B Target Object = Object_B jointpoint = method invocation Weaving
References ,[object Object],[object Object],[object Object],[object Object],[object Object]
Questions?
Slide and Materials ,[object Object],Grazie!

Contenu connexe

Tendances

Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014
Antoine Sabot-Durand
 
The Kotlin Programming Language
The Kotlin Programming LanguageThe Kotlin Programming Language
The Kotlin Programming Language
intelliyole
 
ADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developersADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developers
Bartosz Kosarzycki
 

Tendances (20)

JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?
 
64-bit Loki
64-bit Loki64-bit Loki
64-bit Loki
 
Writing usableap isinpractice
Writing usableap isinpracticeWriting usableap isinpractice
Writing usableap isinpractice
 
C# 6.0 - DotNetNotts
C# 6.0 - DotNetNottsC# 6.0 - DotNetNotts
C# 6.0 - DotNetNotts
 
Eval4j @ JVMLS 2014
Eval4j @ JVMLS 2014Eval4j @ JVMLS 2014
Eval4j @ JVMLS 2014
 
IronSmalltalk
IronSmalltalkIronSmalltalk
IronSmalltalk
 
Demonstration Of The Open Mi
Demonstration Of The Open MiDemonstration Of The Open Mi
Demonstration Of The Open Mi
 
Ekon 25 Python4Delphi_MX475
Ekon 25 Python4Delphi_MX475Ekon 25 Python4Delphi_MX475
Ekon 25 Python4Delphi_MX475
 
Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014
 
An Overview of Project Jigsaw
An Overview of Project JigsawAn Overview of Project Jigsaw
An Overview of Project Jigsaw
 
The Kotlin Programming Language
The Kotlin Programming LanguageThe Kotlin Programming Language
The Kotlin Programming Language
 
Google Dart
Google DartGoogle Dart
Google Dart
 
Parm
ParmParm
Parm
 
Why Spring <3 Kotlin
Why Spring <3 KotlinWhy Spring <3 Kotlin
Why Spring <3 Kotlin
 
From code to pattern, part one
From code to pattern, part oneFrom code to pattern, part one
From code to pattern, part one
 
Bytecode manipulation with Javassist and ASM
Bytecode manipulation with Javassist and ASMBytecode manipulation with Javassist and ASM
Bytecode manipulation with Javassist and ASM
 
Project Coin
Project CoinProject Coin
Project Coin
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
 
RMI (Remote Method Invocation)
RMI (Remote Method Invocation)RMI (Remote Method Invocation)
RMI (Remote Method Invocation)
 
ADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developersADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developers
 

Similaire à Manage software dependencies with ioc and aop

Visual Studio .NET2010
Visual Studio .NET2010Visual Studio .NET2010
Visual Studio .NET2010
Satish Verma
 
Development workflow
Development workflowDevelopment workflow
Development workflow
Sigsiu.NET
 
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
Sang Don Kim
 

Similaire à Manage software dependencies with ioc and aop (20)

Introduction to Software Development
Introduction to Software DevelopmentIntroduction to Software Development
Introduction to Software Development
 
Visual Studio .NET2010
Visual Studio .NET2010Visual Studio .NET2010
Visual Studio .NET2010
 
Eclipse Training - Main eclipse ecosystem classes
Eclipse Training - Main eclipse ecosystem classesEclipse Training - Main eclipse ecosystem classes
Eclipse Training - Main eclipse ecosystem classes
 
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
 
Iron Languages - NYC CodeCamp 2/19/2011
Iron Languages - NYC CodeCamp 2/19/2011Iron Languages - NYC CodeCamp 2/19/2011
Iron Languages - NYC CodeCamp 2/19/2011
 
TWINS: OOP and FP - Warburton
TWINS: OOP and FP - WarburtonTWINS: OOP and FP - Warburton
TWINS: OOP and FP - Warburton
 
Development workflow
Development workflowDevelopment workflow
Development workflow
 
Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)
 
Better Code: Concurrency
Better Code: ConcurrencyBetter Code: Concurrency
Better Code: Concurrency
 
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
 
Intro To Spring Python
Intro To Spring PythonIntro To Spring Python
Intro To Spring Python
 
LLVM
LLVMLLVM
LLVM
 
Lec15a1-Object-Oriented Development.ppt
Lec15a1-Object-Oriented Development.pptLec15a1-Object-Oriented Development.ppt
Lec15a1-Object-Oriented Development.ppt
 
Iron python
Iron pythonIron python
Iron python
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM Mechanics
 
Microservices for building an IDE - The innards of JetBrains Rider - NDC Oslo...
Microservices for building an IDE - The innards of JetBrains Rider - NDC Oslo...Microservices for building an IDE - The innards of JetBrains Rider - NDC Oslo...
Microservices for building an IDE - The innards of JetBrains Rider - NDC Oslo...
 
iOS Development - Offline Class for Jasakomer
iOS Development - Offline Class for JasakomeriOS Development - Offline Class for Jasakomer
iOS Development - Offline Class for Jasakomer
 
Python programming workshop session 1
Python programming workshop session 1Python programming workshop session 1
Python programming workshop session 1
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
 
Mufix Network Programming Lecture
Mufix Network Programming LectureMufix Network Programming Lecture
Mufix Network Programming Lecture
 

Plus de Stefano Leli

Agile retrospective,an example
Agile retrospective,an exampleAgile retrospective,an example
Agile retrospective,an example
Stefano Leli
 
Codice legacy, usciamo dal pantano!
Codice legacy, usciamo dal pantano!Codice legacy, usciamo dal pantano!
Codice legacy, usciamo dal pantano!
Stefano Leli
 
Design Pattern In Pratica
Design Pattern In PraticaDesign Pattern In Pratica
Design Pattern In Pratica
Stefano Leli
 
Workshop Su Refactoring
Workshop Su RefactoringWorkshop Su Refactoring
Workshop Su Refactoring
Stefano Leli
 
Intoduzione Alle Metodologie Agili
Intoduzione Alle Metodologie AgiliIntoduzione Alle Metodologie Agili
Intoduzione Alle Metodologie Agili
Stefano Leli
 

Plus de Stefano Leli (17)

Agile quackery a brief history of the worst ways to cure everything
Agile quackery   a brief history of the worst ways to cure everythingAgile quackery   a brief history of the worst ways to cure everything
Agile quackery a brief history of the worst ways to cure everything
 
Agile goes Hollywood - Un approccio empirico alle trasformazioni agili
Agile goes Hollywood - Un approccio empirico alle trasformazioni agiliAgile goes Hollywood - Un approccio empirico alle trasformazioni agili
Agile goes Hollywood - Un approccio empirico alle trasformazioni agili
 
Succeding with feature teams
Succeding with feature teamsSucceding with feature teams
Succeding with feature teams
 
User Story Mapping
User Story MappingUser Story Mapping
User Story Mapping
 
La tua prima kanban board
La tua prima kanban boardLa tua prima kanban board
La tua prima kanban board
 
Dinosaur Carpaccio - How to implement valuable micro-requirements
Dinosaur Carpaccio - How to implement valuable micro-requirementsDinosaur Carpaccio - How to implement valuable micro-requirements
Dinosaur Carpaccio - How to implement valuable micro-requirements
 
From Vision To Product
From Vision To ProductFrom Vision To Product
From Vision To Product
 
Agile retrospective,an example
Agile retrospective,an exampleAgile retrospective,an example
Agile retrospective,an example
 
User stories writing - Codemotion 2013
User stories writing   - Codemotion 2013User stories writing   - Codemotion 2013
User stories writing - Codemotion 2013
 
User Stories Writing
User Stories WritingUser Stories Writing
User Stories Writing
 
Codice legacy, usciamo dal pantano! @iad11
Codice legacy, usciamo dal pantano! @iad11Codice legacy, usciamo dal pantano! @iad11
Codice legacy, usciamo dal pantano! @iad11
 
XP Game
XP GameXP Game
XP Game
 
Il project manager e lo sviluppo agile. Separati in casa?
Il project manager e lo sviluppo agile. Separati in casa?Il project manager e lo sviluppo agile. Separati in casa?
Il project manager e lo sviluppo agile. Separati in casa?
 
Codice legacy, usciamo dal pantano!
Codice legacy, usciamo dal pantano!Codice legacy, usciamo dal pantano!
Codice legacy, usciamo dal pantano!
 
Design Pattern In Pratica
Design Pattern In PraticaDesign Pattern In Pratica
Design Pattern In Pratica
 
Workshop Su Refactoring
Workshop Su RefactoringWorkshop Su Refactoring
Workshop Su Refactoring
 
Intoduzione Alle Metodologie Agili
Intoduzione Alle Metodologie AgiliIntoduzione Alle Metodologie Agili
Intoduzione Alle Metodologie Agili
 

Dernier

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Dernier (20)

WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

Manage software dependencies with ioc and aop

  • 1. Manage software dependencies with IoC and AOP Stefano Leli 14° Workshop DotNetMarche Friday 16 th April 2010 @sleli [email_address]
  • 2.
  • 3.
  • 4. Dependencies public RequestService() { ClassB b = new ClassB() b.DoService(); } dependent +DoService() ClassA +RequestService() ClassB
  • 5.
  • 6.
  • 7.
  • 8. Copier Example Copier + PerformCopy() Keyboard + ReadFromKB(c : char ) Video + WriteToVideo () : char
  • 9.
  • 10.
  • 11.
  • 12. Copier Example <<create>> <<create>> Concrete class should depend on abstraction Robert Martin IWriter IReader Copier + PerformCopy() Keyboard + Read(c : char ) Video + Write () : char
  • 13.
  • 14.
  • 15.
  • 16. <<create>> Using a Factory <<create>> Copier + Copier(r : IReader, w : IWriter) + PerformCopy() IWriter IReader Keyboard + Read(c : char ) Video + Write () : char ReaderFactory + GetInstance() : IReader WriterFactory + GetInstance() : IWriter
  • 17.
  • 18.
  • 19. Service Locator << create >> <<create>> Copier + PerformCopy() ServiceLocator +Lookup() : Object +RegisterService(o : Object) _instance : ServiceLocator … IWriter IReader Keyboard + Read(c : char ) Video + Write () : char
  • 20. Service Locator << create >> <<create>> Copier + PerformCopy() ServiceLocator +Lookup() : Object +RegisterService(o : Object) _instance : ServiceLocator … IWriter IReader Keyboard + Read(c : char ) Video + Write () : char
  • 21. Service Locator class ServiceLocator { /* Singleton instance */ private static ServiceLocator _instance; public static void Load(ServiceLocator arg) { _instance = arg; } /* Storing and Retrieve services */ private Dictionary<string, Object> _services = new Dictionary<string, Object>(); public Object RegisterService(String key) { return _instance._services[key]; } public static void Lookup(String key, Object service) { _services.Add(key, service); } }
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27. IoC Container Copier + Copier(r : IReader, w : IWriter) + PerformCopy() IWriter IReader Keyboard + Read(c : char ) Video + Write () : char
  • 28. << create >> <<create>> IoC Container <<create>> Copier + Copier(r : IReader, w : IWriter) + PerformCopy() XML Config IWriter IReader Keyboard + Read(c : char ) Video + Write () : char IoCContainer …
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35. Separation of Concern Searching Booking Payment
  • 36.
  • 37.
  • 38. Crosscutting Concern Booking Payment Searching Security Logging AOP Booking Security Logging Payment Security Logging Searching Security Logging OOP Crosscutting Concerns Searching Booking Payment
  • 39. How it works… Object_B Object_A Object Oriented Flow
  • 40. How it works… Aspect Object_B Object_A advice Object Oriented Flow Aspect Oriented Flow pointcut = method_B Target Object = Object_B jointpoint = method invocation
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 49.