1 / 18

Wstrzykiwanie zależności

Wstrzykiwanie zależności. Tomasz Bartoszewski. C o przypomina Twój kod?. Co nas boli. Wszelkie „drobne” zmiany zlecane przez klienta Utrudnione rozszerzanie aplikacji o dodatkowe funkcjonalności Klasy silnie ze sobą powiązane Tworzenie jednych obiektów w innych.

alayna
Télécharger la présentation

Wstrzykiwanie zależności

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Wstrzykiwanie zależności Tomasz Bartoszewski

  2. Co przypomina Twój kod?

  3. Co nas boli • Wszelkie „drobne” zmiany zlecane przez klienta • Utrudnione rozszerzanie aplikacji o dodatkowe funkcjonalności • Klasy silnie ze sobą powiązane • Tworzenie jednych obiektów w innych

  4. Odwrócenie sterowania(Inversion of Control) • „Nie dzwoń do nas, my zadzwonimy do Ciebie” • Stolarz nie rąbie drzew, a mechanik nie wytwarza narzędzi Dostarczaj obiektom to czego potrzebują!

  5. Wstrzykiwanie zależności(Dependency Injection) • Jeden z pomysłów realizacji IoC, obecnie najpopularniejszy • Odwrócone sterowanie czyli tworzenie i wiązanie obiektów

  6. Zalety • Luźne powiązania obiektów • Ułatwiona pielęgnacja kodu, wprowadzania zmian, dalszy rozwój • Dodatkowy profit podczas pisania testów jednostkowych

  7. "Software is always under constant pressure to change, so it's very important to keep your code flexible. Inversion of control helps you break your application into pieces of manageable size, and then glue them back together in a much more flexible way. Then, the next time your client asks you to make a 'little' change to the product, you can laugh triumphantly instead of quivering in pain.“ -Nate Kohari(Creator of Ninject)

  8. Przykłady

  9. Własne wstrzykiwanie zależności

  10. Wykorzystaj gotowe sprawdzone rozwiązania

  11. Wykorzystanie Springa

  12. Druga strona medalu

  13. Ninject

More Related