Dependency injection is your friend
[EuroPython 2011] Alan Franzoni - 24 June 2011 in "Track Spaghetti"
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.