<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Álinson S Xavier on Medium]]></title>
        <description><![CDATA[Stories by Álinson S Xavier on Medium]]></description>
        <link>https://medium.com/@isoron?source=rss-4fbf2276cdaf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*AHyQrVpJxITgFaa1p5p3eA.jpeg</url>
            <title>Stories by Álinson S Xavier on Medium</title>
            <link>https://medium.com/@isoron?source=rss-4fbf2276cdaf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 05:44:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@isoron/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A Friendly Introduction to Dagger 2: Part 2]]></title>
            <link>https://medium.com/@isoron/a-friendly-introduction-to-dagger-2-part-2-87d8c5ab77f0?source=rss-4fbf2276cdaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/87d8c5ab77f0</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Álinson S Xavier]]></dc:creator>
            <pubDate>Tue, 02 Aug 2016 12:02:18 GMT</pubDate>
            <atom:updated>2016-08-14T15:59:05.749Z</atom:updated>
            <content:encoded><![CDATA[<h4>Using modules to specify how objects should be constructed</h4><p>In the<a href="https://medium.com/@isoron/a-friendly-introduction-to-dagger-2-part-1-dbdf2f3fb17b#.85rhz97p2"> previous part of this series</a>, we saw how Dagger 2 allows us to use dependency injection in our applications without having to write long blocks of initialization code by hand.</p><p>As you recall, we created an interface,<em> </em>to let the framework know what types of objects our <em>main</em> method was interested in, and Dagger automatically generated a concrete class that was able to construct instances of those types for us. We never specified <em>how</em> to actually construct these objects or their dependencies. Since all of our classes were concrete and properly annotated, this was not a problem: Dagger could infer, from the annotations, which constructors to invoke whenever an instance of each class was needed.</p><p>Very often, however, classes depend not on <em>concrete</em>, but on <em>abstract</em> classes and interfaces, which have no constructors that can be invoked by Dagger. Sometimes, modifying the source code of a class to include annotations might not be an option. At other times, creating an object requires more than simply invoking a constructor. In all these cases, Dagger’s automatic behavior is not sufficient, and the framework needs our help.</p><p>In today’s post, we will see how to provide additional instructions to Dagger about the construction of some objects by using <strong>modules</strong>. Modules can be easily swapped by each other and can be reused across projects. They can also receive running time arguments, which makes them very flexible.</p><h3>An example</h3><p>To illustrate the situation described above, let’s go back to first example of part 1, where we only had three classes: <em>WeatherReporter</em> and its two dependencies, <em>LocationManager </em>and<em> WeatherService</em>. Both dependencies were concrete classes. In practice, this would probably not be the case.</p><p>Let’s suppose, instead, that <em>WeatherService</em> is an interface, and that we have one more class, say, <em>YahooWeather</em>, that implements that interface:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/989c6ce09c5d61d2e2bd5d9ccd22bf08/href">https://medium.com/media/989c6ce09c5d61d2e2bd5d9ccd22bf08/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fff3c44c4c06918b740f0c524a294a42/href">https://medium.com/media/fff3c44c4c06918b740f0c524a294a42/href</a></iframe><p>If we try to compile the project again, Dagger will give us an error saying that it could not find a <strong>provider</strong> for <em>WeatherService</em>.</p><p>When a class is concrete and has an annotated constructor, Dagger can automatically generate a provider for that class. Since <em>WeatherService</em> is an interface, however, we must give Dagger more information.</p><h3>What are modules?</h3><p>For now, <strong>modules</strong> are classes that are able to build objects of certain types. The following module, for example, is able to create <em>WeatherService</em> objects upon request by instantiating the class <em>YahooWeather</em>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f0e0af9230b2063c4b71bb6cda42ffc6/href">https://medium.com/media/f0e0af9230b2063c4b71bb6cda42ffc6/href</a></iframe><p>Modules should receive the <em>@Module</em> annotation. Some of their methods, known as <strong>provider methods,</strong> receive the <em>Provides </em>annotation to indicate that they can provide instances of a certain type upon request. The names of the methods are not important: Dagger only looks at the signatures.</p><p>With this module definition, we enhance Dagger’s abilities to create objects and satisfy dependencies. Before, only concrete classes with annotated constructors were allowed as dependencies, but now, with this module, any class can depend on our <em>WeatherService </em>interface. We just need to connect this module to the component that our entry point uses:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/befd52d0adc00507964656febd46933a/href">https://medium.com/media/befd52d0adc00507964656febd46933a/href</a></iframe><p>The project now compiles again, and every <em>WeatherReporter</em> constructed by the method <em>getWeatherReporter</em> is given an instance of <em>YahooWeather</em>.</p><p>We are free to either define one huge module that knows how to build every abstract class and interface in the application, or many small modules that only know how to build closely related classes. In this series, we will use the latter approach.</p><h3>How to swap modules</h3><p>One of the most interesting properties of modules is that they can be easily swapped by each other. This allows us to have multiple implementations of an interface in our project, and to easily switch between.</p><p>Suppose, for example, that we have another concrete class, <em>WeatherChannel,</em> that also implements <em>WeatherService</em>. If we want to use this concrete class in our <em>WeatherReporter</em> instead of the previous <em>YahooWeather</em>, we can write a new module <em>WeatherChannelModule</em> and then replace the previous module by this one in our component, as follows.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/540a89038f42086972ee57edf9d79dba/href">https://medium.com/media/540a89038f42086972ee57edf9d79dba/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/92e0a911359da6edfae8c81434059d64/href">https://medium.com/media/92e0a911359da6edfae8c81434059d64/href</a></iframe><p>Swapping modules is useful, for example, when writing integration or end-to-end tests. We can define another component which is almost identical to the production one, but that uses some different modules. I will go into more details about this in another post.</p><p>If we try to plug two different modules that provide the same type into a component, Dagger will throw a compilation error, telling us that the <em>type is bound multiple times</em>. For example, we are not allowed to do this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e116f441c042b3d0768cd0fae989a8b9/href">https://medium.com/media/e116f441c042b3d0768cd0fae989a8b9/href</a></iframe><p>Also, since Dagger 2 generates the components during compilation, modules cannot be replaced during running time. Our entry point, however, can have multiple components at its disposal, and decide which component to ask objects from according to some running time conditions.</p><h3>Building more complex objects</h3><p>Now that we know what modules are and how to write some basic ones, let’s see how can we write modules that build some more complex objects. For example, objects defined by third-parties (whose classes cannot be modified), that have dependencies, or that require configuration.</p><h4>Building third-party objects</h4><p>Sometimes modifying a class to include annotations is not an option. The class, for example, might be provided by a framework or some external library. Third-party classes often have very questionable design too, and might not lend themselves easily to dependency injection frameworks.</p><p>Suppose, for example, that our <em>LocationManager</em> class depends on <em>GpsSensor</em>. This class, however, was provided by the Acme Corporation, and cannot be modified. To make things worse, the constructor for this class doesn’t fully initialize it. After instantiating this class, we still need to call a number of methods, such as <em>calibrate</em>, before the object can actually be used. Below is the source code for <em>LocationManager</em> and <em>GpsSensor</em>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ee3bcd8f0b4ffbb4325ee2ba92c15ab6/href">https://medium.com/media/ee3bcd8f0b4ffbb4325ee2ba92c15ab6/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dc81c06823dfac6ede32f439fb08cf40/href">https://medium.com/media/dc81c06823dfac6ede32f439fb08cf40/href</a></iframe><p>Note that <em>GpsSensor</em> has no annotations. Since Acme Corporation’s products <em>just work</em>, they have no need for dependency injection or tests.</p><p>We would like to avoid having the constructor of <em>LocationManager</em> call the <em>calibrate </em>method since setting up a <em>GpsSensor</em> is not its responsibility. Ideally, all dependencies received should be <em>ready to use</em>. This instance of <em>GpsSensor</em> might also be shared among multiple objects, and Acme Corporation warned us that calling the <em>calibrate</em> method multiple times causes a crash.</p><p>To safely use <em>GpsSensor</em>, we can write a module whose sole responsibility is to create and configure this object upon request. In this way, any class can depend on <em>GpsSensor </em>without having to worry about its initialization.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a8357324306a512d0d5f2a505b1033db/href">https://medium.com/media/a8357324306a512d0d5f2a505b1033db/href</a></iframe><h4>Building objects with dependencies</h4><p>Sometimes our modules must create objects that have dependencies. It is not the module’s responsibility to create these dependencies, or to go looking around for them. Like other classes, the module can also assume that these dependencies will be provided.</p><p>Let’s suppose, for example, that the class <em>YahooWeather </em>requires a <em>WebSocket </em>to work. The code for both of these classes is shown below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1b79e0c926f3a074257dd7fb545405af/href">https://medium.com/media/1b79e0c926f3a074257dd7fb545405af/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5f056974f1be0d59da8491d040ccba0b/href">https://medium.com/media/5f056974f1be0d59da8491d040ccba0b/href</a></iframe><p>Now that the constructor of <em>YahooWeather</em> requires a parameter, our <em>YahooWeatherModule</em> must be modified. We need to obtain, somehow, an instance of a <em>WebSocket</em> in order to invoke the constructor<em>.</em></p><p>Instead of instantiating the dependency inside the module, which would lead to all the shortcomings of not using dependency injection, we can just modify the signature of the provider method, as shown below. Dagger will take care of finding or constructing a <em>WebSocket </em>for the module to use.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5872bb3d7647bc6c667b80f010ee3a61/href">https://medium.com/media/5872bb3d7647bc6c667b80f010ee3a61/href</a></iframe><h4>Building objects that must be configured</h4><p>Sometimes a module needs to create an object that must be configured somehow, and this configuration might require a piece of information that only becomes available at running time.</p><p>Continuing our example, let’s suppose that the constructor of <em>YahooWeather</em> also requires an API key. Here is the modified class.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/67f4d4fac65706711c59b241a07a5897/href">https://medium.com/media/67f4d4fac65706711c59b241a07a5897/href</a></iframe><p>Note that we removed the <em>Inject</em> annotation. Since the construction of <em>YahooWeather</em> is being handled by our module, there is no need for Dagger to know about this constructor. Dagger would also not know how to inject a meaningful <em>String</em> parameter automatically (although this can also be done, as we will see in a future post).</p><p>If the API key is a constant available at compile time somewhere, say, in a class named <em>BuildConfig</em>, then a possible solution is the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e140551113e9bd52664e71ec7228d57e/href">https://medium.com/media/e140551113e9bd52664e71ec7228d57e/href</a></iframe><p>Suppose, however, that the API key is only available at running time. For example, it could be a command-line argument. This information can be provided to the module, just like any other dependency, via its constructor.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/748a8be2a0065aa917c8dea096493daa/href">https://medium.com/media/748a8be2a0065aa917c8dea096493daa/href</a></iframe><p>This complicates things a little for Dagger, since now it has no idea how to construct such a module. When modules have no-argument constructors, then Dagger can easily instantiate and use them. In this case, however, we must instantiate the module ourselves and give it to Dagger. This can be done as follows, at the entry point for the application:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e4b089f14b449515b6728f4a0a32f4ae/href">https://medium.com/media/e4b089f14b449515b6728f4a0a32f4ae/href</a></iframe><p>In lines 3–4 we grabbed the API key from the command-line arguments and instantiated the module ourselves. In lines 5–7, we asked Dagger to build a new component, using that instance of our module. Instead of calling the method <em>create</em>, we obtained a <em>builder</em> instead, passed the instantiated module, and then called <em>build</em>.</p><p>If there were more modules in our component that Dagger was unable to instantiate automatically, we would need to make one call to set each of these modules before calling <em>build</em>.</p><h3>Conclusion</h3><p>In today’s post we saw how to take more control over the creation of objects by using modules. <a href="https://github.com/iSoron/dagger2-examples/tree/master/part-2">The source code for this post can be found at GitHub</a>.</p><p>In the next post, we will see how to specify that some dependencies can be shared among multiple objects. If you have any questions, comments or suggestions, please let me know.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87d8c5ab77f0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Friendly Introduction to Dagger 2: Part 1]]></title>
            <link>https://medium.com/@isoron/a-friendly-introduction-to-dagger-2-part-1-dbdf2f3fb17b?source=rss-4fbf2276cdaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/dbdf2f3fb17b</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Álinson S Xavier]]></dc:creator>
            <pubDate>Sat, 30 Jul 2016 15:36:50 GMT</pubDate>
            <atom:updated>2016-08-14T15:57:55.050Z</atom:updated>
            <content:encoded><![CDATA[<h4>What is dependency injection, what is Dagger, and how can they help us write cleaner, more testable code.</h4><p>Dependency injection is a great technique to increase the testability of an application and Dagger 2 is one of the most popular dependency injection frameworks currently available for Java and Android. Most introductory guides to Dagger 2, however, assume that the reader is already deeply familiar with dependency injection and its heavy terminology, making it hard for newcomers to jump on board.</p><p>In this series of posts, I will try to give you a more friendly introduction to Dagger 2, with plenty of complete code samples that you can actually compile and modify.</p><p>To keep things practical and concise, I have deliberately left out all the history of dependency injection frameworks, as well as the endless variations. We will start with one specific flavor of dependency injection (constructor injection) and visit other variations as we move along.</p><h3>So, what is dependency injection?</h3><p>Dependency injection is a technique that makes classes more easy to test and to reuse. To see how can we apply it, let’s start with an example. Suppose that we need to write an application that prints the current weather conditions on the console. A naive implementation could look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f5c9ccf2ff3267da4824d293211f7d03/href">https://medium.com/media/f5c9ccf2ff3267da4824d293211f7d03/href</a></iframe><p>Some methods have been omitted, since they are not important. The focus here is that, in order to perform its job, a <em>WeatherReporter</em> needs two other objects: a <em>LocationManager</em>, which can detect the current user’s location, and a <em>WeatherService</em>, which can provide the temperature for any given location.</p><p>In a well designed object-oriented application, each object has only a very small number of responsibilities, and rely on other objects to accomplish most of the work. These other objects are called <strong>dependencies</strong>. Before an object can start doing real work, all of its dependencies must be <strong>satisfied </strong>somehow. The dependencies for our <em>WeatherReporter</em>, for example, are satisfied by creating new instances of them on the constructor.</p><p>While instantiating dependencies on the constructor works well enough for small applications, it comes with a number of shortcomings as the application evolves. First, it makes the class rather inflexible. If this app is supposed to run on multiple platforms, for example, we might want to swap a certain <em>LocationManager</em> by another, but this cannot be easily done. Perhaps, we would also like to share the same <em>LocationManager</em> among multiple objects, but this is also hard to accomplish, unless the class is modified.</p><p>Secondly, it is impossible to test our class in isolation. Constructing a single <em>WeatherReporter</em> will always automatically construct two other objects, which will end up getting tested along with the original object. This can be a serious problem if one of these dependencies relies on an expensive external resource such as a network connection, or if it has a large number of dependencies itself.</p><p>Both problems arise because our class has two distinct responsibilities. It must not only know <em>how</em> to perform a certain task, but also <em>where</em> to find the collaborators it needs to accomplish it. If, instead, we provide to our object everything it needs to perform its job, then the previous problems disappear. The class can easily work with different collaborators and can be tested in isolation.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a47ab49d12e797b6652c126dcbc0f3c9/href">https://medium.com/media/a47ab49d12e797b6652c126dcbc0f3c9/href</a></iframe><p>This approach is called <strong>dependency injection</strong>. In an application that relies on dependency injection, the objects never have to hunt around for dependencies or construct them themselves. All the dependencies are provided to them, or <strong>injected</strong> into them, ready to be used.</p><h3>Building the graph</h3><p>At some point, of course, someone has to instantiate the dependencies and actually provide them to the objects that might require them. This phase, called <strong>building the dependency graph</strong>, is usually done at the entry point of the application. On the desktop, for example, this code would be found inside the <em>main</em> method, as shown below. On Android, it could be done inside an <em>Activity</em>’s <em>onCreate </em>method.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/53195373643973bfedb463808686b285/href">https://medium.com/media/53195373643973bfedb463808686b285/href</a></iframe><p>If the project is as simple as our previous example, then instantiating and injecting a few dependencies manually on the main method is very reasonable. Most projects, however, have dozens of classes, each with various dependencies that need to be satisfied. Instantiating and wiring everything together requires a lot of code. Even worse, this code will constantly have to change every time a new class is added to the application, or any time an existing class is modified to require a new dependency.</p><p>To illustrate this problem, let’s make our small example a little more realistic. In practice, a <em>WeatherService</em> would probably require, say, a <em>WebSocket</em> to communicate over the network. A <em>LocationManager</em> would require a <em>GPSProvider</em> to communicate with the hardware, and most classes could also require a <em>Logger</em>, to print useful debugging information on the console. The modified main function would look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/831528819b3e59ebf247226ed422806f/href">https://medium.com/media/831528819b3e59ebf247226ed422806f/href</a></iframe><p>Very quickly, the entry point for our application has started to become bloated with initialization code. To build a single <em>WeatherReporter</em>, which is the object we actually care about, we had to manually instantiate numerous others. As the application grows and more classes are added, this main method will keep growing until it becomes completely unmanageable.</p><h3>How can Dagger 2 help?</h3><p><strong>Dagger 2</strong> is an open source tool that can generate most of that initialization code automatically for us based on a few annotations. Using Dagger 2, the entry point of our application can be written with just a few lines of code, regardless of how many classes we have and how many dependencies they require. Below is the new <em>main</em> method for our example, using Dagger.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/92870e43773b8beea34cc46a23ca14e2/href">https://medium.com/media/92870e43773b8beea34cc46a23ca14e2/href</a></iframe><p>Note that we did not have to write a single line of code to instantiate any of the dependencies, or to specify how these dependencies are interconnected. This is done automatically for us. The class <em>DaggerAppComponent</em>, which is automatically generated during the compilation of the project, is clever enough to know, for example, that a <em>WeatherReporter</em> needs a <em>Logger</em>, a <em>LocationManager</em> and a <em>WeatherService</em>, which in turn need a <em>GPSProvider</em> and a <em>WebSocket</em>. With a single call to <em>getWeatherReporter</em>, it builds all these objects in the correct sequence, wires them together, and returns just what we asked for.</p><p>For Dagger to work, we need to perform a few steps. First, we need to add an annotation to the constructor of every class that Dagger needs to know about. Below, we show how this can be done for one specific class, but we also need to annotate every class that either requires some dependencies, or that is required by someone.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c23885e163e6e7f5bf69445e9267e02/href">https://medium.com/media/7c23885e163e6e7f5bf69445e9267e02/href</a></iframe><p>If you are worried about polluting your application with Dagger-specific code, then you will be pleased to know that the <em>Inject</em> annotation has been standardized (JSR 330) and works with many other tools, such as Spring and Guice. Switching to another dependency injection framework, then, can be done without modifying every class in the application.</p><p>For the next step, we need to create an interface, annotated as <em>Component</em>, containing methods that return the objects we need. It’s not necessary to create one method for each class in our project, but only for classes that are directly used by the entry point of the application. In our example, the <em>main</em> method only needs a <em>WeatherReporter</em>, so our component only needs one method, as shown below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3d087c55f9acf829d24d7717e3df3f2c/href">https://medium.com/media/3d087c55f9acf829d24d7717e3df3f2c/href</a></iframe><p>The only step left is to integrate Dagger with our build system. Using Gradle, this can be done by adding some new dependencies to the <em>build.gradle</em> file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/22989bee8cf5331fd1863f11eeb2e8fd/href">https://medium.com/media/22989bee8cf5331fd1863f11eeb2e8fd/href</a></iframe><p>The project can already be compiled and executed. If you would like to try it yourself, the entire source code for this example is <a href="https://github.com/iSoron/dagger2-examples">available at GitHub</a>.</p><p>As a closing remark, note that every class in the project can still be used without Dagger, just as before. We can still, for example, instantiate a <em>Logger</em> manually using the <em>new </em>operator, perhaps during a unit test. Dagger does not modify the behavior of the language. It simply generates some convenience classes that know how to initialize objects for us.</p><p><a href="https://medium.com/@isoron/a-friendly-introduction-to-dagger-2-part-2-87d8c5ab77f0#.gndutup94">In the next post of this series</a>, we will see happens when the same dependency can be satisfied by multiple classes, or when we cannot annotate a class for some reason. If you have any questions, comments or suggestions, please let me know in the comments below.</p><h4>Further reading</h4><p>If you are not entirely convinced of the benefits of dependency injection, or would like to see more examples where it improves testability, please have a look at the the amazing guide <a href="http://misko.hevery.com/code-reviewers-guide/">Writing Testable Code</a>, written by Miško Hevery, Russ Ruffer and Jonathan Wolter.</p><p>If you are more interested in the theory of dependency injection and all the variations out there, I recommend the essay <a href="http://www.martinfowler.com/articles/injection.html">Inversion of Control Containers and the Dependency Injection pattern</a>, by Martin Fowler.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dbdf2f3fb17b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>