Summary

In this chapter we explored swapping test doubles using Inversion of Control (IoC). This is not the only use case for IoC. Being able to easily reconfigure things with no impact to the core business logic is of incredible value.

IoC allows us to move object creation to a centralized location. This empowers our applications to be easier to inject alternatives. This makes things such as testing, remoting, transactions, and security much easier.

Spring Python supports many formats including pure Python, Spring Python XML, and Spring Java XML. This gives users a wide range of choices based on their needs. By working with Jython, it is much easier to mix together Python and Java code together.

Exchanging one object definition with another constitutes a useful service. Throughout this book, other services will be explored. Just remember, at the heart of those services is Spring Python's IoC container.

In this chapter, we learned:

  • IoC containers make it easy to isolate objects under test by swapping production collaborators with test doubles
  • Detailed definitions of IoC and Dependency Injection
  • IoC containers positively impact our application by separating creation of objects from their usage, and this helps modularize our applications
  • The Hollywood principle of Dependency Injection means that our objects don't create their collaborators, but instead wait for the container to create them and inject them into our object
  • Spring Python has an ObjectContainer with the basic parts of an IoC container. This container handles dependency resolution, setting properties, and lazy initialiation
  • Spring Python has an ApplicationContext, that subclasses the container, and provides extension points for developers to manipulate creation of objects
  • While there may be debate about using IoC in dynamic languages, the benefits of delegating object creation to a separate container is not confined to just static languages
  • By using Spring Python's container with Jython, it is easy to mix Python and Java components together. This tactic is even more productive for applications that were already built with Spring Java

In the next chapter, we will look at adding services to existing code using Aspect Oriented Programming (AOP).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.179.225