Update readme

This commit is contained in:
Roman Mogilatov 2016-10-07 17:32:24 +03:00
parent 5c3b58d653
commit 55c7473b6f

View File

@ -42,13 +42,6 @@ Status
| | :alt: Coverage Status | | | :alt: Coverage Status |
+---------------------------------------+----------------------------------------------------------------------------------------+ +---------------------------------------+----------------------------------------------------------------------------------------+
Installation
------------
*Dependency Injector* library is available on `PyPi`_::
pip install dependency_injector
Dependency Injection Dependency Injection
-------------------- --------------------
@ -65,14 +58,20 @@ Dependency injection pattern has few strict rules that should be followed:
injector) the responsibility of providing its dependencies - object **B** injector) the responsibility of providing its dependencies - object **B**
(the service). (the service).
+ The client doesn't know how to create the service, it knows only interface + The client doesn't know how to create the service, it knows only interface
of service. of service. The service doesn't know that it is used by the client.
+ The service doesn't know that it is used by the client. + The dependency injector knows how to create the client and the service, it
+ The dependency injector knows how to create the client. also knows that the client depends on the service, and knows how to inject
+ The dependency injector knows how to create the service. the service into the client.
+ The dependency injector knows that the client depends on the service. + The client and the service know nothing about the dependency injector.
+ The dependency injector knows how to inject the service into the client.
+ The client knows nothing about the dependency injector. Dependency injection pattern provides next advantages:
+ The service knows nothing about the dependency injector.
+ Control on application structure.
+ Decreased coupling between application components.
+ Increased code reusability.
+ Increased testability.
+ Increased maintainability.
+ Reconfiguration of system without rebuilding.
Next two examples demonstrate refactoring of a small piece of code to Next two examples demonstrate refactoring of a small piece of code to
dependency injection pattern: dependency injection pattern:
@ -123,18 +122,6 @@ realistic, right?
engine = Engine() # Application creates Engine's instance engine = Engine() # Application creates Engine's instance
car = Car(engine) # and inject it into the Car's instance car = Car(engine) # and inject it into the Car's instance
Advantages of dependency injection
----------------------------------
Dependency injection pattern provides next advantages:
+ Control on application structure.
+ Decreased coupling between application components.
+ Increased code reusability.
+ Increased testability.
+ Increased maintainability.
+ Reconfiguration of system without rebuilding.
Example of dependency injection Example of dependency injection
------------------------------- -------------------------------
@ -293,6 +280,13 @@ GitHub:
https://github.com/ets-labs/python-dependency-injector https://github.com/ets-labs/python-dependency-injector
Installation
------------
*Dependency Injector* library is available on `PyPi`_::
pip install dependency_injector
Documentation Documentation
------------- -------------