{
    "href": "/post/2012/06/07/tldr-of-di-vs-sl/",
    "relId": "2012/06/07/tldr-of-di-vs-sl",
    "title": "tl;dr of DI vs SL",
    "author": "pmjones",
    "markup": "html",
    "tags": [
        {
            "href": "/tag/php/",
            "relId": "php",
            "title": "PHP",
            "author": null,
            "created": null,
            "updated": [],
            "markup": "markdown"
        },
        {
            "href": "/tag/programming/",
            "relId": "programming",
            "title": "Programming",
            "author": null,
            "created": null,
            "updated": [],
            "markup": "markdown"
        }
    ],
    "created": "2012-06-07 16:04:42 UTC",
    "updated": [
        "2012-06-07 16:04:42 UTC"
    ],
    "html": "<p>Chris Hartjes has a nice writeup on <a href=\"http://www.littlehart.net/atthekeyboard/2012/06/06/dic-vs-service-locator/\">dependency injection containers versus service locators</a>. Here's a short way to tell which one you're using:</p>\n<p><strong>\"If your class has a dependency on a container, you're using Service Locator, not Dependency Injection.\"</strong></p>\n<p>If you have a DI container and you pass it into a class so that class can get its own dependencies from that container, you are *still* doing Service Locator. It doesn't matter that the locator is called a DI container. The key is that the object is pulling in its dependencies, instead of something outside of the object pushing the dependencies into it.</p>\n"
}
