SlideShare uma empresa Scribd logo
1 de 5
Baixar para ler offline
Inversion of Control
Dependency Injection

  Florian Motlik 13.10.2008
 JSUG - Treffen 1 WS 08/09
Inversion of Control

  Don't call us, we call you.
   Trennung Kontrolle und Ausführung
  Generische Kontrollklasse und spezifische
  Implementierung
  Iterator vs Code Block/Closure
  stooges = ['Larry', 'Curly', 'Moe']
      foreach (stooge in stooges) {print stooge + quot;nquot;}
          Kontrolle der Iterierung in Hand des Programmierers
      stooges.each {|stooge| print stooge + quot;nquot;}
          each Methode kontrolliert Iterierung. Interne
          Iterierung.
   Event-driven programming - z.B. Swing Gui Listener
Dependency Injection

 Anwendung von IOC
 Kontrolle über Dependencies




 Kopplung von App zu SortImpl verringern
 Kein direkter Aufruf eines SortImpl Konstrukturs
 Sorter wird quot;Injectedquot; in App durch Framework
 Setter & Constructor based Injection
Vorteile/Nachteile

  Vorteile
     Weniger Abhängigkeiten (Kapselung)
     Kein lookup Code nötig
     Zwang zu Interfaces -> bessere Struktur
     Test/Run Konfiguration möglich und nur einmal zu
     machen.
  Nachteile
     Möglicherweise viel Konfiguration (XML Hell)
     Zusätzliches Framework
     Abhängigkeiten zum Framework (vermeidbar)
     Refaktorisierung umständlich/fehleranfällig (IDE)
     Weniger Code Transparenz
Links

   http://en.wikipedia.org/wiki/Dependency_injection
   http://en.wikipedia.org/wiki/Inversion_of_control
   http://en.wikipedia.org/wiki/Strategy_pattern
   http://en.wikipedia.org/wiki/Closure_(computer_science)
   http://martinfowler.com/articles/injection.html


Licensed under CreativeCommons Attribution + ShareAlike (by-sa)
http://creativecommons.org/licenses/by-sa/3.0/at/

Mais conteúdo relacionado

Destaque

OpenBib und Linked Open Data - Weiterentwicklung eines Recherche-Portals
OpenBib und Linked Open Data - Weiterentwicklung eines Recherche-PortalsOpenBib und Linked Open Data - Weiterentwicklung eines Recherche-Portals
OpenBib und Linked Open Data - Weiterentwicklung eines Recherche-Portalsflimm
 
Google über alles? Wissenschaftssuchmaschinen als alternativer Weg zu releva...
Google über alles?  Wissenschaftssuchmaschinen als alternativer Weg zu releva...Google über alles?  Wissenschaftssuchmaschinen als alternativer Weg zu releva...
Google über alles? Wissenschaftssuchmaschinen als alternativer Weg zu releva...hubert3
 
EKS-Strategie: Erfolgsprinzipien
EKS-Strategie: ErfolgsprinzipienEKS-Strategie: Erfolgsprinzipien
EKS-Strategie: ErfolgsprinzipienStephan List
 
Workshop (DE): Führen mit flexiblen Zielen, organized by Coaching Institute
Workshop (DE): Führen mit flexiblen Zielen, organized by Coaching InstituteWorkshop (DE): Führen mit flexiblen Zielen, organized by Coaching Institute
Workshop (DE): Führen mit flexiblen Zielen, organized by Coaching InstituteGebhard Borck
 
Erzähler Tristan Letztes Kapitel Rossbach
Erzähler  Tristan Letztes  Kapitel  RossbachErzähler  Tristan Letztes  Kapitel  Rossbach
Erzähler Tristan Letztes Kapitel RossbachJoerg Hartmann
 
Wirtschaftsspanisch lernen | Spanischkurse in Spanien: Kurse für Wirtschaftss...
Wirtschaftsspanisch lernen | Spanischkurse in Spanien: Kurse für Wirtschaftss...Wirtschaftsspanisch lernen | Spanischkurse in Spanien: Kurse für Wirtschaftss...
Wirtschaftsspanisch lernen | Spanischkurse in Spanien: Kurse für Wirtschaftss...Alhambra Instituto
 
Martin Delius: "Transparente Politik kapern mit Social Media?"
Martin Delius: "Transparente Politik kapern mit Social Media?"Martin Delius: "Transparente Politik kapern mit Social Media?"
Martin Delius: "Transparente Politik kapern mit Social Media?"Socialbar
 
Sprachkurse Spanien Spanisch Lernen Sprachreisen Spanien Sprachschulen
Sprachkurse Spanien Spanisch Lernen Sprachreisen Spanien SprachschulenSprachkurse Spanien Spanisch Lernen Sprachreisen Spanien Sprachschulen
Sprachkurse Spanien Spanisch Lernen Sprachreisen Spanien SprachschulenAlhambra Instituto
 
091204 Vhs Literaturgeschichte I Antike
091204 Vhs  Literaturgeschichte  I  Antike091204 Vhs  Literaturgeschichte  I  Antike
091204 Vhs Literaturgeschichte I AntikeJoerg Hartmann
 
Keynote (DE): Beyond Budgeting Transformation, at Cognos Performance 2008, Ma...
Keynote (DE): Beyond Budgeting Transformation, at Cognos Performance 2008, Ma...Keynote (DE): Beyond Budgeting Transformation, at Cognos Performance 2008, Ma...
Keynote (DE): Beyond Budgeting Transformation, at Cognos Performance 2008, Ma...Gebhard Borck
 
Africa
AfricaAfrica
Africasasia
 
Freiwillige und lobbyarbeit
Freiwillige und lobbyarbeitFreiwillige und lobbyarbeit
Freiwillige und lobbyarbeitSocialbar
 
Der Kölner UniversitätsGesamtkatalog (KUG)
Der Kölner UniversitätsGesamtkatalog (KUG)Der Kölner UniversitätsGesamtkatalog (KUG)
Der Kölner UniversitätsGesamtkatalog (KUG)flimm
 
Archäologische Dateninfrastrukturen
Archäologische DateninfrastrukturenArchäologische Dateninfrastrukturen
Archäologische DateninfrastrukturenKai-Christian Bruhn
 
Hotel Schloss Wilhelminenberg
Hotel Schloss WilhelminenbergHotel Schloss Wilhelminenberg
Hotel Schloss Wilhelminenberghanhdoan
 

Destaque (20)

OpenBib und Linked Open Data - Weiterentwicklung eines Recherche-Portals
OpenBib und Linked Open Data - Weiterentwicklung eines Recherche-PortalsOpenBib und Linked Open Data - Weiterentwicklung eines Recherche-Portals
OpenBib und Linked Open Data - Weiterentwicklung eines Recherche-Portals
 
FOTOS
FOTOSFOTOS
FOTOS
 
Google über alles? Wissenschaftssuchmaschinen als alternativer Weg zu releva...
Google über alles?  Wissenschaftssuchmaschinen als alternativer Weg zu releva...Google über alles?  Wissenschaftssuchmaschinen als alternativer Weg zu releva...
Google über alles? Wissenschaftssuchmaschinen als alternativer Weg zu releva...
 
EKS-Strategie: Erfolgsprinzipien
EKS-Strategie: ErfolgsprinzipienEKS-Strategie: Erfolgsprinzipien
EKS-Strategie: Erfolgsprinzipien
 
Wissenswertes zu globo-study Sprachreisen
Wissenswertes zu globo-study SprachreisenWissenswertes zu globo-study Sprachreisen
Wissenswertes zu globo-study Sprachreisen
 
Workshop (DE): Führen mit flexiblen Zielen, organized by Coaching Institute
Workshop (DE): Führen mit flexiblen Zielen, organized by Coaching InstituteWorkshop (DE): Führen mit flexiblen Zielen, organized by Coaching Institute
Workshop (DE): Führen mit flexiblen Zielen, organized by Coaching Institute
 
Erzähler Tristan Letztes Kapitel Rossbach
Erzähler  Tristan Letztes  Kapitel  RossbachErzähler  Tristan Letztes  Kapitel  Rossbach
Erzähler Tristan Letztes Kapitel Rossbach
 
Families
FamiliesFamilies
Families
 
Wirtschaftsspanisch lernen | Spanischkurse in Spanien: Kurse für Wirtschaftss...
Wirtschaftsspanisch lernen | Spanischkurse in Spanien: Kurse für Wirtschaftss...Wirtschaftsspanisch lernen | Spanischkurse in Spanien: Kurse für Wirtschaftss...
Wirtschaftsspanisch lernen | Spanischkurse in Spanien: Kurse für Wirtschaftss...
 
vhs Nobelpreise II
vhs Nobelpreise IIvhs Nobelpreise II
vhs Nobelpreise II
 
Martin Delius: "Transparente Politik kapern mit Social Media?"
Martin Delius: "Transparente Politik kapern mit Social Media?"Martin Delius: "Transparente Politik kapern mit Social Media?"
Martin Delius: "Transparente Politik kapern mit Social Media?"
 
Buster
BusterBuster
Buster
 
Sprachkurse Spanien Spanisch Lernen Sprachreisen Spanien Sprachschulen
Sprachkurse Spanien Spanisch Lernen Sprachreisen Spanien SprachschulenSprachkurse Spanien Spanisch Lernen Sprachreisen Spanien Sprachschulen
Sprachkurse Spanien Spanisch Lernen Sprachreisen Spanien Sprachschulen
 
091204 Vhs Literaturgeschichte I Antike
091204 Vhs  Literaturgeschichte  I  Antike091204 Vhs  Literaturgeschichte  I  Antike
091204 Vhs Literaturgeschichte I Antike
 
Keynote (DE): Beyond Budgeting Transformation, at Cognos Performance 2008, Ma...
Keynote (DE): Beyond Budgeting Transformation, at Cognos Performance 2008, Ma...Keynote (DE): Beyond Budgeting Transformation, at Cognos Performance 2008, Ma...
Keynote (DE): Beyond Budgeting Transformation, at Cognos Performance 2008, Ma...
 
Africa
AfricaAfrica
Africa
 
Freiwillige und lobbyarbeit
Freiwillige und lobbyarbeitFreiwillige und lobbyarbeit
Freiwillige und lobbyarbeit
 
Der Kölner UniversitätsGesamtkatalog (KUG)
Der Kölner UniversitätsGesamtkatalog (KUG)Der Kölner UniversitätsGesamtkatalog (KUG)
Der Kölner UniversitätsGesamtkatalog (KUG)
 
Archäologische Dateninfrastrukturen
Archäologische DateninfrastrukturenArchäologische Dateninfrastrukturen
Archäologische Dateninfrastrukturen
 
Hotel Schloss Wilhelminenberg
Hotel Schloss WilhelminenbergHotel Schloss Wilhelminenberg
Hotel Schloss Wilhelminenberg
 

Semelhante a JSUG - Inversion Of Control by Florian Motlik

2009 03 17 Spring101
2009 03 17 Spring1012009 03 17 Spring101
2009 03 17 Spring101gueste4be40
 
Offensive Security – Das Metasploit Framework
Offensive Security – Das Metasploit FrameworkOffensive Security – Das Metasploit Framework
Offensive Security – Das Metasploit FrameworkQAware GmbH
 
AdvancedTdd
AdvancedTddAdvancedTdd
AdvancedTddjlink
 
Automatisiertes webauftritt testen
Automatisiertes webauftritt testenAutomatisiertes webauftritt testen
Automatisiertes webauftritt testenmradamlacey
 
Große Applikationen mit AngularJS
Große Applikationen mit AngularJSGroße Applikationen mit AngularJS
Große Applikationen mit AngularJSSebastian Springer
 
Advanced ASP.NET 2 05.10.2010
Advanced  ASP.NET 2 05.10.2010Advanced  ASP.NET 2 05.10.2010
Advanced ASP.NET 2 05.10.2010Albert Weinert
 
Unit testing mit Javascript
Unit testing mit JavascriptUnit testing mit Javascript
Unit testing mit Javascriptjoergreichert
 
Informatik Seminar Groovy Und Grails
Informatik Seminar Groovy Und GrailsInformatik Seminar Groovy Und Grails
Informatik Seminar Groovy Und Grailsschmichri
 
Advanced Refactoring Patterns
Advanced Refactoring PatternsAdvanced Refactoring Patterns
Advanced Refactoring PatternsHendrik Lösch
 
Advanced Refactoring Patterns - Dev Day 2018
Advanced Refactoring Patterns - Dev Day 2018Advanced Refactoring Patterns - Dev Day 2018
Advanced Refactoring Patterns - Dev Day 2018Hendrik Lösch
 

Semelhante a JSUG - Inversion Of Control by Florian Motlik (14)

2009 03 17 Spring101
2009 03 17 Spring1012009 03 17 Spring101
2009 03 17 Spring101
 
Offensive Security – Das Metasploit Framework
Offensive Security – Das Metasploit FrameworkOffensive Security – Das Metasploit Framework
Offensive Security – Das Metasploit Framework
 
MVVM mit WPF
MVVM mit WPFMVVM mit WPF
MVVM mit WPF
 
AdvancedTdd
AdvancedTddAdvancedTdd
AdvancedTdd
 
Automatisiertes webauftritt testen
Automatisiertes webauftritt testenAutomatisiertes webauftritt testen
Automatisiertes webauftritt testen
 
Große Applikationen mit AngularJS
Große Applikationen mit AngularJSGroße Applikationen mit AngularJS
Große Applikationen mit AngularJS
 
Advanced ASP.NET 2 05.10.2010
Advanced  ASP.NET 2 05.10.2010Advanced  ASP.NET 2 05.10.2010
Advanced ASP.NET 2 05.10.2010
 
Unit testing mit Javascript
Unit testing mit JavascriptUnit testing mit Javascript
Unit testing mit Javascript
 
Iks Sonderdruck Eclipse Magazin Mai 2010: Automatisierte SWTBot-Tests
Iks Sonderdruck Eclipse Magazin Mai 2010: Automatisierte SWTBot-TestsIks Sonderdruck Eclipse Magazin Mai 2010: Automatisierte SWTBot-Tests
Iks Sonderdruck Eclipse Magazin Mai 2010: Automatisierte SWTBot-Tests
 
Informatik Seminar Groovy Und Grails
Informatik Seminar Groovy Und GrailsInformatik Seminar Groovy Und Grails
Informatik Seminar Groovy Und Grails
 
Advanced Refactoring Patterns
Advanced Refactoring PatternsAdvanced Refactoring Patterns
Advanced Refactoring Patterns
 
Advanced Refactoring Patterns - Dev Day 2018
Advanced Refactoring Patterns - Dev Day 2018Advanced Refactoring Patterns - Dev Day 2018
Advanced Refactoring Patterns - Dev Day 2018
 
UnitTests? Ja, aber richtig!
UnitTests? Ja, aber richtig!UnitTests? Ja, aber richtig!
UnitTests? Ja, aber richtig!
 
Design OOA OOD
Design OOA OODDesign OOA OOD
Design OOA OOD
 

Mais de Christoph Pickl

JSUG - AS3 vs Java by Christoph Pickl
JSUG - AS3 vs Java by Christoph PicklJSUG - AS3 vs Java by Christoph Pickl
JSUG - AS3 vs Java by Christoph PicklChristoph Pickl
 
JSUG - Layouting TeX documents with the Memoir class
JSUG - Layouting TeX documents with the Memoir classJSUG - Layouting TeX documents with the Memoir class
JSUG - Layouting TeX documents with the Memoir classChristoph Pickl
 
JSUG - Cocoon3 Student Project Idea by Reinhard Poetz and Steven Dolg
JSUG - Cocoon3 Student Project Idea by Reinhard Poetz and Steven DolgJSUG - Cocoon3 Student Project Idea by Reinhard Poetz and Steven Dolg
JSUG - Cocoon3 Student Project Idea by Reinhard Poetz and Steven DolgChristoph Pickl
 
JSUG - ActionScript 3 vs Java by Christoph Pickl
JSUG - ActionScript 3 vs Java by Christoph PicklJSUG - ActionScript 3 vs Java by Christoph Pickl
JSUG - ActionScript 3 vs Java by Christoph PicklChristoph Pickl
 
JSUG - TeX, LaTeX und der Rest by Norbert Preining
JSUG - TeX, LaTeX und der Rest by Norbert PreiningJSUG - TeX, LaTeX und der Rest by Norbert Preining
JSUG - TeX, LaTeX und der Rest by Norbert PreiningChristoph Pickl
 
JSUG - TeX Day by Christoph Pickl
JSUG - TeX Day by Christoph PicklJSUG - TeX Day by Christoph Pickl
JSUG - TeX Day by Christoph PicklChristoph Pickl
 
JSUG - The Sound of Shopping by Christoph Pickl
JSUG - The Sound of Shopping by Christoph PicklJSUG - The Sound of Shopping by Christoph Pickl
JSUG - The Sound of Shopping by Christoph PicklChristoph Pickl
 
JSUG - Tim aka EPROG2 by Martin Schuerrer
JSUG - Tim aka EPROG2 by Martin SchuerrerJSUG - Tim aka EPROG2 by Martin Schuerrer
JSUG - Tim aka EPROG2 by Martin SchuerrerChristoph Pickl
 
JSUG - Java Service Enabler by Andreas Hubmer
JSUG - Java Service Enabler by Andreas HubmerJSUG - Java Service Enabler by Andreas Hubmer
JSUG - Java Service Enabler by Andreas HubmerChristoph Pickl
 
JSUG - Hoppla by Florian Motlik and Petar Petrov
JSUG - Hoppla by Florian Motlik and Petar PetrovJSUG - Hoppla by Florian Motlik and Petar Petrov
JSUG - Hoppla by Florian Motlik and Petar PetrovChristoph Pickl
 
JSUG - Google Web Toolkit by Hans Sowa
JSUG - Google Web Toolkit by Hans SowaJSUG - Google Web Toolkit by Hans Sowa
JSUG - Google Web Toolkit by Hans SowaChristoph Pickl
 
JSUG - TU Wien Cocoon Project by Andreas Pieber
JSUG - TU Wien Cocoon Project by Andreas PieberJSUG - TU Wien Cocoon Project by Andreas Pieber
JSUG - TU Wien Cocoon Project by Andreas PieberChristoph Pickl
 
JSUG - TU Wien Castor Project by Lukas Lang
JSUG - TU Wien Castor Project by Lukas LangJSUG - TU Wien Castor Project by Lukas Lang
JSUG - TU Wien Castor Project by Lukas LangChristoph Pickl
 
JSUG - LaTeX Introduction by Christoph Pickl
JSUG - LaTeX Introduction by Christoph PicklJSUG - LaTeX Introduction by Christoph Pickl
JSUG - LaTeX Introduction by Christoph PicklChristoph Pickl
 
JSUG - OSGi by Michael Greifeneder
JSUG - OSGi by Michael GreifenederJSUG - OSGi by Michael Greifeneder
JSUG - OSGi by Michael GreifenederChristoph Pickl
 
JSUG - Filthy Flex by Christoph Pickl
JSUG - Filthy Flex by Christoph PicklJSUG - Filthy Flex by Christoph Pickl
JSUG - Filthy Flex by Christoph PicklChristoph Pickl
 
JSUG - Seam by Florian Motlik
JSUG - Seam by Florian MotlikJSUG - Seam by Florian Motlik
JSUG - Seam by Florian MotlikChristoph Pickl
 
JSUG - Google Guice by Jan Zarnikov
JSUG - Google Guice by Jan ZarnikovJSUG - Google Guice by Jan Zarnikov
JSUG - Google Guice by Jan ZarnikovChristoph Pickl
 
JSUG - Java FX by Christoph Pickl
JSUG - Java FX by Christoph PicklJSUG - Java FX by Christoph Pickl
JSUG - Java FX by Christoph PicklChristoph Pickl
 
JSUG - Tech Tips1 by Christoph Pickl
JSUG - Tech Tips1 by Christoph PicklJSUG - Tech Tips1 by Christoph Pickl
JSUG - Tech Tips1 by Christoph PicklChristoph Pickl
 

Mais de Christoph Pickl (20)

JSUG - AS3 vs Java by Christoph Pickl
JSUG - AS3 vs Java by Christoph PicklJSUG - AS3 vs Java by Christoph Pickl
JSUG - AS3 vs Java by Christoph Pickl
 
JSUG - Layouting TeX documents with the Memoir class
JSUG - Layouting TeX documents with the Memoir classJSUG - Layouting TeX documents with the Memoir class
JSUG - Layouting TeX documents with the Memoir class
 
JSUG - Cocoon3 Student Project Idea by Reinhard Poetz and Steven Dolg
JSUG - Cocoon3 Student Project Idea by Reinhard Poetz and Steven DolgJSUG - Cocoon3 Student Project Idea by Reinhard Poetz and Steven Dolg
JSUG - Cocoon3 Student Project Idea by Reinhard Poetz and Steven Dolg
 
JSUG - ActionScript 3 vs Java by Christoph Pickl
JSUG - ActionScript 3 vs Java by Christoph PicklJSUG - ActionScript 3 vs Java by Christoph Pickl
JSUG - ActionScript 3 vs Java by Christoph Pickl
 
JSUG - TeX, LaTeX und der Rest by Norbert Preining
JSUG - TeX, LaTeX und der Rest by Norbert PreiningJSUG - TeX, LaTeX und der Rest by Norbert Preining
JSUG - TeX, LaTeX und der Rest by Norbert Preining
 
JSUG - TeX Day by Christoph Pickl
JSUG - TeX Day by Christoph PicklJSUG - TeX Day by Christoph Pickl
JSUG - TeX Day by Christoph Pickl
 
JSUG - The Sound of Shopping by Christoph Pickl
JSUG - The Sound of Shopping by Christoph PicklJSUG - The Sound of Shopping by Christoph Pickl
JSUG - The Sound of Shopping by Christoph Pickl
 
JSUG - Tim aka EPROG2 by Martin Schuerrer
JSUG - Tim aka EPROG2 by Martin SchuerrerJSUG - Tim aka EPROG2 by Martin Schuerrer
JSUG - Tim aka EPROG2 by Martin Schuerrer
 
JSUG - Java Service Enabler by Andreas Hubmer
JSUG - Java Service Enabler by Andreas HubmerJSUG - Java Service Enabler by Andreas Hubmer
JSUG - Java Service Enabler by Andreas Hubmer
 
JSUG - Hoppla by Florian Motlik and Petar Petrov
JSUG - Hoppla by Florian Motlik and Petar PetrovJSUG - Hoppla by Florian Motlik and Petar Petrov
JSUG - Hoppla by Florian Motlik and Petar Petrov
 
JSUG - Google Web Toolkit by Hans Sowa
JSUG - Google Web Toolkit by Hans SowaJSUG - Google Web Toolkit by Hans Sowa
JSUG - Google Web Toolkit by Hans Sowa
 
JSUG - TU Wien Cocoon Project by Andreas Pieber
JSUG - TU Wien Cocoon Project by Andreas PieberJSUG - TU Wien Cocoon Project by Andreas Pieber
JSUG - TU Wien Cocoon Project by Andreas Pieber
 
JSUG - TU Wien Castor Project by Lukas Lang
JSUG - TU Wien Castor Project by Lukas LangJSUG - TU Wien Castor Project by Lukas Lang
JSUG - TU Wien Castor Project by Lukas Lang
 
JSUG - LaTeX Introduction by Christoph Pickl
JSUG - LaTeX Introduction by Christoph PicklJSUG - LaTeX Introduction by Christoph Pickl
JSUG - LaTeX Introduction by Christoph Pickl
 
JSUG - OSGi by Michael Greifeneder
JSUG - OSGi by Michael GreifenederJSUG - OSGi by Michael Greifeneder
JSUG - OSGi by Michael Greifeneder
 
JSUG - Filthy Flex by Christoph Pickl
JSUG - Filthy Flex by Christoph PicklJSUG - Filthy Flex by Christoph Pickl
JSUG - Filthy Flex by Christoph Pickl
 
JSUG - Seam by Florian Motlik
JSUG - Seam by Florian MotlikJSUG - Seam by Florian Motlik
JSUG - Seam by Florian Motlik
 
JSUG - Google Guice by Jan Zarnikov
JSUG - Google Guice by Jan ZarnikovJSUG - Google Guice by Jan Zarnikov
JSUG - Google Guice by Jan Zarnikov
 
JSUG - Java FX by Christoph Pickl
JSUG - Java FX by Christoph PicklJSUG - Java FX by Christoph Pickl
JSUG - Java FX by Christoph Pickl
 
JSUG - Tech Tips1 by Christoph Pickl
JSUG - Tech Tips1 by Christoph PicklJSUG - Tech Tips1 by Christoph Pickl
JSUG - Tech Tips1 by Christoph Pickl
 

JSUG - Inversion Of Control by Florian Motlik

  • 1. Inversion of Control Dependency Injection Florian Motlik 13.10.2008 JSUG - Treffen 1 WS 08/09
  • 2. Inversion of Control Don't call us, we call you. Trennung Kontrolle und Ausführung Generische Kontrollklasse und spezifische Implementierung Iterator vs Code Block/Closure stooges = ['Larry', 'Curly', 'Moe'] foreach (stooge in stooges) {print stooge + quot;nquot;} Kontrolle der Iterierung in Hand des Programmierers stooges.each {|stooge| print stooge + quot;nquot;} each Methode kontrolliert Iterierung. Interne Iterierung. Event-driven programming - z.B. Swing Gui Listener
  • 3. Dependency Injection Anwendung von IOC Kontrolle über Dependencies Kopplung von App zu SortImpl verringern Kein direkter Aufruf eines SortImpl Konstrukturs Sorter wird quot;Injectedquot; in App durch Framework Setter & Constructor based Injection
  • 4. Vorteile/Nachteile Vorteile Weniger Abhängigkeiten (Kapselung) Kein lookup Code nötig Zwang zu Interfaces -> bessere Struktur Test/Run Konfiguration möglich und nur einmal zu machen. Nachteile Möglicherweise viel Konfiguration (XML Hell) Zusätzliches Framework Abhängigkeiten zum Framework (vermeidbar) Refaktorisierung umständlich/fehleranfällig (IDE) Weniger Code Transparenz
  • 5. Links http://en.wikipedia.org/wiki/Dependency_injection http://en.wikipedia.org/wiki/Inversion_of_control http://en.wikipedia.org/wiki/Strategy_pattern http://en.wikipedia.org/wiki/Closure_(computer_science) http://martinfowler.com/articles/injection.html Licensed under CreativeCommons Attribution + ShareAlike (by-sa) http://creativecommons.org/licenses/by-sa/3.0/at/