{
    "href": "/post/2012/12/20/on-decoupling-and-dependencies-answering-the-critics-of-auras-approach/",
    "relId": "2012/12/20/on-decoupling-and-dependencies-answering-the-critics-of-auras-approach",
    "title": "On Decoupling and Dependencies: Answering The Critics of Aura's Approach",
    "author": "pmjones",
    "markup": "html",
    "tags": [
        {
            "href": "/tag/aura/",
            "relId": "aura",
            "title": "Aura",
            "author": null,
            "created": "2020-09-14 21:51:57 UTC",
            "updated": [
                "2020-09-14 21:51:57 UTC"
            ],
            "markup": "markdown"
        },
        {
            "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-12-20 21:26:50 UTC",
    "updated": [
        "2012-12-20 21:26:50 UTC"
    ],
    "html": "<blockquote>\n<p>\"There are no solutions ... only trade-offs.\" -- Thomas Sowell</p>\n</blockquote>\n<p>tl;dr: \"As a library <em>author</em> it\u00e2\u0080\u0099s tempting to bring in dependencies for various reasons, but as a library <em>user</em> it\u00e2\u0080\u0099s frequently convenient to not have cascading dependency sets. ... If a user already has something they like, make it as easy as possible for them to keep using it <em>without</em> making them install things they don't actually need. That is the kind of duplication we really want to avoid. This applies not only to HTTP response delivery, but to caching, logging, translation, templating, and a host of other functionality.\"</p>\n<hr>\n<p>Recent articles from me and others regarding <a href=\"http://auraphp.github.com\">the Aura project for PHP 5.4+</a>, dependencies, and decoupling have generated a lot of commentary, some of it negative, and some of it misdirected.  For reference, the posts are:</p>\n<ul>\n<li><a href=\"http://paul-m-jones.com/archives/4152\">How Is Aura Better Than (er, Different From ;-) Than Symfony and Zend?</a></li>\n<li><a href=\"http://paul-m-jones.com/archives/4176\">Aura: More Decoupled Than Symfony 2 and Zend Framework 2</a></li>\n<li><a href=\"http://paul-m-jones.com/archives/4194\">Aura.Micro: Experimental Replacement for Silex</a></li>\n</ul>\n<p>In this post, I'll respond to some of that commentary.  I will sum up similar comments and address those summaries.</p>\n<h3>Regarding \"Dependencies Are Bad\"</h3>\n<p>Bernhard \"Webmozart\" Schussek writes <a href=\"http://webmozarts.com/2012/12/15/on-libraries-and-dependencies\">an otherwise good post</a> that, unfortunately, begins by misconstruing my statements:</p>\n<blockquote>\n<p>Aura is creating some buzz that components of PHP frameworks should not have any dependencies.</p>\n<p>...</p>\n<p>The general attitude of people arguing against dependencies is that dependencies are a bad thing.</p>\n</blockquote>\n<p><a href=\"http://paul-m-jones.com/archives/4152/comment-page-1#comment-434747\">Matt Robinson</a> makes a related comment:</p>\n<blockquote>\n<p>You\u00e2\u0080\u0099ve made a judgement call that dependencies should be avoided at all costs \u00e2\u0080\u0093 I think that\u00e2\u0080\u0099s going a bit too far. </p>\n</blockquote>\n<p>I can understand how some readers might infer the \"dependencies are bad\" sentiment from the interviews, especially if they did not read with thoughtful consideration. Their assessment is incorrect.</p>\n<p>For the record: dependencies are not a bad thing in and of themselves, nor are they a good thing in and of themselves.  Choosing to have one or more dependencies is a trade-off in software development, where the gains and losses from having the dependency must be judged according to the context of the development goals.</p>\n<p>If dependencies are neither good nor bad in themselves, why does Aura avoid them so assiduously?  </p>\n<p>To learn the answer, please recall <a href=\"http://paul-m-jones.com/archives/4152\">the origin of the Aura project</a> (which is essentially the second major version of the Solar framework):</p>\n<blockquote>\n<p>One of the repeated questions we got regarding Solar went like this: \u00e2\u0080\u009cI want to use just one part of Solar; can I do that without having to download and configure the whole framework?\u00e2\u0080\u009d Of course the answer to that was \u00e2\u0080\u009cnot really.\u00e2\u0080\u009d It was a monolithic framework, where all the pieces were designed to work with each other in a relatively dependent fashion.</p>\n<p>So with Aura, we started out from the other direction. We wanted the pieces to be usable on their own, without any other dependencies. Only after that would we build a framework out of the pieces.</p>\n</blockquote>\n<p>As you can see, it is expressly our goal to serve a particular set of users as our primary focus:  those who want independent libraries without added dependencies.</p>\n<p>As a library <em>author</em> it's tempting to bring in dependencies for various reasons, but as a library <em>user</em> it's frequently convenient to not have cascading dependency sets.  Call it a case of taking our audience seriously, and going as far as we can with it.</p>\n<h3>Regarding \"Duplication\"</h3>\n<p><a href=\"http://paul-m-jones.com/archives/4152/comment-page-1#comment-434747\">Matt Robinson</a> asks:</p>\n<blockquote>\n<p>[W]hat\u00e2\u0080\u0099s the real difference between <a href=\"https://github.com/auraphp/Aura.Http/blob/develop/src/Aura/Http/Message/Response.php\">AuraHttpMessageResponse</a> and <a href=\"https://github.com/auraphp/Aura.Web/blob/develop/src/Aura/Web/Response.php\">AuraWebResponse</a>? They look remarkably similar and have significant overlap in interface and purpose. I might be wrong, but it looks like you\u00e2\u0080\u0099ve got this big chunk of duplicated effort for the sake of avoiding one line in a composer.json file. :)</p>\n</blockquote>\n<p>They <em>are</em> remarkably similar, since they serve a similar purpose; that is, to describe an HTTP response.  I think \"big chunk\" is an inaccurate characterization, though; it's 2 classes out of 56 between both packages.</p>\n<p>As Matt allows, he is in fact wrong. ;-) The duplication is not for the sake of avoiding one line in a Composer file.  It is to make sure that people who want to use <a href=\"https://github.com/auraphp/Aura.Web\">Aura.Web</a> package are not required to additionally install the entire <a href=\"https://github.com/auraphp/Aura.Web\">Aura.Http</a> package to get access to a single class.</p>\n<p>Many library users out there already have HTTP delivery mechanisms of their own choosing, and have neither the desire nor the inclination to drag another one into their codebase.  All these users need is a way to describe an HTTP response. It's easy to do that in a single file.</p>\n<p>Because of this single class of duplication that exists in Aura.Web, library users can build a relatively small amount of glue code to send the <code>AuraWebResponse</code> using their existing installation of <a href=\"http://guzzlephp.org/\">Guzzle</a>, <a href=\"https://github.com/kriswallsmith/Buzz\">Buzz</a>, <a href=\"http://php.net/http\">the HTTP extension</a>, <a href=\"http://image.slidesharecdn.com/decoupled-121201120108-phpapp01/95/slide-50-638.jpg\">plain old PHP</a>, or even the <a href=\"https://github.com/auraphp/Aura.Http\">Aura.Http</a> package.  This is the tradeoff: a single duplicated file, versus many dozens of files of duplicated, unused, and unneeded functionality.</p>\n<p>That is the central point for the Aura project: if a user already has something they like, make it as easy as possible for them to keep using it <em>without</em> making them install things they don't actually need. That is the kind of duplication we really want to avoid. This applies not only to HTTP response delivery, but to caching, logging, translation, templating, and a host of other functionality.</p>\n<p><a href=\"http://webmozarts.com/2012/12/15/on-libraries-and-dependencies/#comment-82214\">Stan</a>, who admittedly is part of the Aura target audience, already knows this:</p>\n<blockquote>\n<p>[T]here are some of us out there that have a hybrid of components tooled together. The more dependencies that are forced on us (guilty by assoc) the harder that is to do. So maybe my app that\u00e2\u0080\u0099s routed by Aura, templated by Twig, works with the DB using Doctrine ODM, utilizes Symfony for the Finder and Yaml components and Zend for the console could find itself in a pickle when more baggage is added to the mix through dependencies that might not be necessary.</p>\n</blockquote>\n<p><a href=\"http://paul-m-jones.com/archives/4176/comment-page-1#comment-434545\">Amy Stephen</a> also figured out the point pretty quickly ...</p>\n<blockquote>\n<p>Disagree with Paul\u00e2\u0080\u0099s assertion in the comments that such a strategy does not lead to some duplication of code or function or that the methodology means some functionality be sacrificed. Of course, it does. That\u00e2\u0080\u0099s the ying and the yang of it \u00e2\u0080\u0093 get one thing clean and another dirty \u00e2\u0080\u0093 the cost, time, quality triangle \u00e2\u0080\u0093 It\u00e2\u0080\u0099s math. It\u00e2\u0080\u0099s always a balancing act building software.</p>\n</blockquote>\n<p>... although to be fair, I didn't say \"does not lead to some duplication\"; I said duplicated code was \"almost nonexistent.\" ;-)  Perhaps that too was a mischaracterization: a few classes here and there, among hundreds of classes and a dozen packages, seems rather small to me. Others may disagree.</p>\n<h3>Regarding \"Not Invented Here\"</h3>\n<p>Some commenters claim that this approach promotes \"NIH\" syndrome. <a href=\"http://paul-m-jones.com/archives/4176/comment-page-1#comment-434442\">Drak</a> said:</p>\n<blockquote>\n<p>Seems to me like you are promoting NIH. The very concept that a decoupled component cant have dependencies means you have to invent everything yourself.</p>\n</blockquote>\n<p><a href=\"http://webmozarts.com/2012/12/15/on-libraries-and-dependencies/\">Webmozart</a> similarly opined:</p>\n<blockquote>\n<p>I think this needs some urgent clarification before this way of thinking becomes mainstream and PHP creeps back into its NIH-hole.</p>\n</blockquote>\n<p>I would argue that the offering decoupled packages in the way the Aura does leads <em>away</em> from not-invented-here syndrome, not toward it.</p>\n<p>Recall that one of the driving motivations behind Aura was to extract the parts of Solar that users wanted as separate packages.  Those users wanted very badly <em>not</em> to engage in NIH by using Solar, but could not, because it was delivered as a monolithic whole.  Those users can now download independent, decoupled Aura packages and avoid rewriting the functionality contained therein.</p>\n<p><a href=\"http://webmozarts.com/2012/12/15/on-libraries-and-dependencies/#comment-83557\">Bertrand</a> lobbed a shot over the net at, I guess, the Symfony crowd, when he said:</p>\n<blockquote>\n<p>Ha, ha, who\u00e2\u0080\u0099s got the NIH syndrom ?</p>\n<p>Event_Dispatcher, written in 2005, 3 years before the one in your example...</p>\n<p><a href=\"http://pear.php.net/package/event_dispatcher\">http://pear.php.net/package/event_dispatcher</a></p>\n</blockquote>\n<p id=\"scroll_to_here\">This is a comment I sympathize with. It seems to me that many accusations of NIH-ism are more complaints and frustrations that the accused is not using the libraries and packages the accuser prefers.</p>\n<h3>Regarding \"Tests As A Way Of Discovering Dependencies\"</h3>\n<p>Some commenters were dissatsifed with my use of unit testing requirements to discover what a package <em>really</em> depends on, as opposed to what its composer.json file states.  <a href=\"http://paul-m-jones.com/archives/4176/comment-page-1#comment-434514\">Webmozart</a> said:</p>\n<blockquote>\n<p>There\u00e2\u0080\u0099s a distinction between required dependencies and optional, supported libraries. For example, the Symfony2 Validator <em>optionally</em> supports annotations, in which case you need DoctrineCommon (why should it reinvent annotation parsing?). You <em>can</em> use the Validator without any of these supported libraries.</p>\n<p>Obviously, the support for these libraries is tested, so for running the tests you also need the supported libraries (doh). I fail to see how this is bad.</p>\n</blockquote>\n<p><a href=\"http://paul-m-jones.com/archives/4176/comment-page-1#comment-434564\">Lukas</a> covered this as well:</p>\n<blockquote>\n<p>[T]he issue is that the way [Paul] was comparing. Paul was making a very incorrect conclusion that anything that is needed to run the tests illustrates \u00e2\u0080\u009ccross-package dependencies\u00e2\u0080\u009d. Yet if you look at the composer.json (which I would have expected Paul to be familiar with) then you would notice that infact the Validator component has ZERO dependencies beyond PHP itself:</p>\n<p>https://github.com/symfony/Validator/blob/master/composer.json</p>\n</blockquote>\n<p>This was a topic I had hoped I would not have to address.  All my other statements regarding dependencies have been as clinical as I could make them, without reference to words like \"good\" or \"bad\" in describing the various practices. For this topic, though, I must make some statements that others will find negative or perjorative.  Because of that, I am going to do it in an entirely separate post, so as not to pollute this commentary thread too harshly. Look for it in a few days.</p>\n<h3>Conclusion</h3>\n<p>Thanks to everyone for their comments and critique, and please be sure to check out <a href=\"http://auraphp.github.com\">the Aura project</a>!</p>\n"
}
