# Dependency Injection

**#Purpose**

To implement a loosely coupled architecture in order to get better testable, maintainable and extendable code.

**#Usage**

DatabaseConfiguration gets injected and DatabaseConnection will get all that it needs from $config. Without DI, the configuration would be created directly in DatabaseConnection, which is not very good for testing and extending it.

**#UML Diagram**

![uml.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1621300685644/zfQVFhPI_.png)

