Support unavailable
Please try again later

Dependency injection is your friend

by Alan Franzoni for EuroPython 2011

Dependency injection is a technique that has been around since long, and it’s widely used in many programming languages and environments, but it’s not that widespread in the Python world.

Many think that using dependency injection will force writing large-and-complex xml blobs, break encapsulation, or reduce code readability, or just that it’s unneeded in an highly expressive language like Python is.

On the contrary, I’ll show you that DI: - doesn’t require any library or framework; - encourages peer role identification; - helps keeping a class focused and cohesive; - encourages separation between wiring from applicative code; - makes your code more reusable, expressive and testable; - doesn’t break encapsulation; - turns part of your coding efforts into configuration

Large applications, by the way, might just get a great maintenance boost by using a real DI container, hence I’ll briefly cover Pydenji, the Python(ic) dependency injection toolkit, and what it can do for your application.

A basic knowledge of object oriented design and SOLID principles is required in order to fully appreciate the content of this talk.

Comments

  1. Gravatar
    How does this relate to configuration management? Please in the talk give examples of what can and can't be done by change the PYTHONPATH.
  2. Gravatar
    I'll need to strip down the talk a bit because of schedule constraints (the talk was designed to be 60 minutes long while the slot is 45 minutes only) - by the way if you need to change the PYTHONPATH you're probably not doing it so right about DI.

New comment


Language
EN
Duration
60 minutes (inc Q&A)
Our Sponsors
Spotify
Python Experts
SSL Matrix
Wanna sponsor?