PHP dependency injection

Object-oriented (OO) programming involves dependencies between objects, such as objects that require a connection to a database object. It’s inevitable and required. The only other option would be duplicate code in every object, defeating the purpose of OO programming. The amount of dependency is the degree that one component relies on another to perform its responsibilities. High dependency limits code reuse and makes moving components to new projects difficult. Lower dependency is better. The key question then is how to manage the dependencies. Some people suggest they should be ‘injected’ into each object. Dependency Injection (DI) is the solution to the principle of Inversion of Control (IoC). It manages the dependencies between objects by creating the dependent objects outside the object which uses that dependency. In other words instead of objects configuring themselves they are configured by an external entity. In software engineering, IoC is an object-oriented programming practice where the object coupling is bound at run time by an assembler object and is typically not known at compile time …

Recent posts

Need something?

Search here

ABOUT DECOMPRESSION

Decompression is a web and software development studio. Our main focus is on intelligent and innovative projects. Our small team of developers are highly skilled and love programming. We also have a full time graphic designer who handles the aesthetics.

Decompression has been a registered company since 2004.

P: +61 (0) 7 5641 2550
E: tristan@decompression.com.au