Skip to main content

Command Palette

Search for a command to run...

Dependency Injection

Published
1 min readView as Markdown

#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

More from this blog

Khang Nguyen

119 posts