<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Daniel Mwakanema</title>
    <description>The latest articles on Forem by Daniel Mwakanema (@danielmwakanema).</description>
    <link>https://forem.com/danielmwakanema</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F15950%2Fc8164a2f-068c-4d81-b9c5-bd21d7ed164d.jpeg</url>
      <title>Forem: Daniel Mwakanema</title>
      <link>https://forem.com/danielmwakanema</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/danielmwakanema"/>
    <language>en</language>
    <item>
      <title>One Design Pattern Per Day (Day 2)</title>
      <dc:creator>Daniel Mwakanema</dc:creator>
      <pubDate>Tue, 07 May 2019 19:31:55 +0000</pubDate>
      <link>https://forem.com/danielmwakanema/one-design-pattern-per-day-day-2-4g7o</link>
      <guid>https://forem.com/danielmwakanema/one-design-pattern-per-day-day-2-4g7o</guid>
      <description>&lt;h2&gt;
  
  
  A little context
&lt;/h2&gt;

&lt;p&gt;A few steps back in time, a client "discovered a way" to make more than what was marketed by a certain pyramid scheme. Essentially, con the con-men.&lt;/p&gt;

&lt;p&gt;The scheme has a site through which you can create accounts for a fee and if a certain criteria is met, you get rewards. As expected the whole process builds, you guessed it, a pyramid.&lt;/p&gt;

&lt;p&gt;I accepted, mostly due to interest in implementing the solution, :).&lt;/p&gt;

&lt;h2&gt;
  
  
  NB:
&lt;/h2&gt;

&lt;p&gt;Anything that needs further explanation has a link attached to it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Approach?
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Site has no API-like entity so I chose &lt;a href="https://en.wikipedia.org/wiki/Headless_browser"&gt;Headless Browsing&lt;/a&gt; using &lt;a href="http://www.nightmarejs.org/"&gt;Nightmare.js&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Persistence with &lt;a href="https://en.wikipedia.org/wiki/MongoDB"&gt;MongoDB&lt;/a&gt; using the &lt;a href="http://www.mysqltutorial.org/mysql-adjacency-list-tree/"&gt;Adjacency List Model&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://restfulapi.net/"&gt;REST API&lt;/a&gt; in &lt;a href="https://nodejs.org/"&gt;Node.js&lt;/a&gt; because there is also a &lt;a href="https://reactjs.org/"&gt;React&lt;/a&gt; application the client needed.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Problem for the day?
&lt;/h2&gt;

&lt;p&gt;This one is a bit trivial. The requirements specified a number of ways to build the pyramid and under certain conditions the application needs to switch between these ways. Essentially, switch its behavior. So having seen it before I thought I'd use the &lt;a href="https://refactoring.guru/design-patterns/strategy"&gt;Strategy Pattern&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For this application I am using JavaScript which is &lt;a href="http://wiki.c2.com/?DynamicTyping"&gt;dynamically typed&lt;/a&gt; and from my small knowledge does not have constructs like interfaces so we'll follow the &lt;a href="http://wiki.c2.com/?LetItCrash"&gt;let-it-fail&lt;/a&gt; ideology in the case that a strategy is given that does not implement what we expect.&lt;/p&gt;

&lt;h2&gt;
  
  
  How am going I to implement it?
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Create Strategies using the &lt;a href="https://gist.github.com/zcaceres/bb0eec99c02dda6aac0e041d0d4d7bf2"&gt;Revealing Module Pattern&lt;/a&gt;. You could do this using a &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function"&gt;Function constructor&lt;/a&gt; as well by attaching accessible members to &lt;code&gt;this&lt;/code&gt;. &lt;/li&gt;
&lt;li&gt;Create a Context function that uses simple &lt;a href="https://en.wikipedia.org/wiki/Dependency_injection"&gt;dependency injection&lt;/a&gt; to receive a strategy and alters its behavior with the change in strategy. The Context I assume provides a recognized point of access to our 1..N strategies.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The application then chooses strategies and accesses them through the Context. Again I did not run this code, not sure why.&lt;/p&gt;

&lt;h2&gt;
  
  
  The strategies:
&lt;/h2&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;StrategyB&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;//more private members here&lt;/span&gt;

  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;execute&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// do stuff in here&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;execute&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;StrategyA&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// more private members here&lt;/span&gt;

  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;execute&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// do more stuff here&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;execute&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  The context:
&lt;/h2&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;Context&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Strategy&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;strategy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Strategy&lt;/span&gt;

    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;execute&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;strategy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setStrategy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;strategy&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;strategy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;strategy&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; 
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Usage:
&lt;/h2&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;context&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;A_DEFAULT_STRATEGY_OF_YOUR_CHOICE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;SOMETHING&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;SOMETHING_ELSE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setStrategy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;StrategyA&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="c1"&gt;// ... and the ladder goes on&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I had a bit of trouble with this one but to me using this pattern allows me to independently implement each strategy while worrying less about writing messy code. With time I may gain more insight into it.&lt;/p&gt;

</description>
      <category>practice</category>
      <category>designpatterns</category>
    </item>
    <item>
      <title>One Design Pattern Per Day (Day 1); Also first post</title>
      <dc:creator>Daniel Mwakanema</dc:creator>
      <pubDate>Mon, 06 May 2019 06:15:52 +0000</pubDate>
      <link>https://forem.com/danielmwakanema/one-design-pattern-per-day-day-1-also-first-post-3480</link>
      <guid>https://forem.com/danielmwakanema/one-design-pattern-per-day-day-1-also-first-post-3480</guid>
      <description>&lt;h2&gt;
  
  
  For the why?
&lt;/h2&gt;

&lt;p&gt;Well design patterns are not really a strong point of mine and naturally to get better we have to do. It will not be perfect so your criticism is welcome.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem for the day?
&lt;/h2&gt;

&lt;p&gt;In recent times I got the chance to watch another developer work. The developer was writing an application that talks to a particular API. The API had recently undergone revisions and upper-management wanted the application to be able to talk to both versions depending on the deployment configuration.&lt;/p&gt;

&lt;h2&gt;
  
  
  How did the developer solve the problem?
&lt;/h2&gt;

&lt;p&gt;The developer used the &lt;code&gt;if&lt;/code&gt; control structure under each route in the application to execute the appropriate code for three versions of the API.&lt;/p&gt;

&lt;h2&gt;
  
  
  Perceived issues with approach?
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Very long and bloated functions&lt;/li&gt;
&lt;li&gt;Hard to understand code&lt;/li&gt;
&lt;li&gt;Too many levels of abstraction under each route&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  My thoughts?
&lt;/h2&gt;

&lt;p&gt;From my point of view, the problem involves selecting an API version and from that creating the appropriate API instance. Seems like it could fall under class instantiation and object creation.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I may have done it (the instantiation at least)?
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Create an interface that defines the API&lt;/li&gt;
&lt;li&gt;Have any version implement it&lt;/li&gt;
&lt;li&gt;Create a factory to create the appropriate instance given a version&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So erm, the code would look like the following (there may be errors, don't care):&lt;/p&gt;

&lt;h3&gt;
  
  
  The interface:
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;API&lt;/span&gt;
  &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;doSomething&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;doOneMoreThing&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  The API instances:
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ApiV1&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="no"&gt;API&lt;/span&gt;
  &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;doSomething&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
    &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// doing something&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;doOneMoreThing&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
    &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// doing one more thing&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ApiV2&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="no"&gt;API&lt;/span&gt;
  &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;doSomething&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
    &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// doing something but slightly differently&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;doOneMoreThing&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
    &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// doing one more thing but slightly differently&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  The factory:
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;APIFactory&lt;/span&gt;
  &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;Map&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="no"&gt;API&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;apiMap&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;  &lt;span class="nc"&gt;Map&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;ofEntries&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;entry&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"v1"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;ApiV1&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt;
                                                     &lt;span class="n"&gt;entry&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"v2"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;ApiV2&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="no"&gt;API&lt;/span&gt; &lt;span class="nf"&gt;getApiIstance&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(!&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;apiMap&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;containsKey&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;IllegalArgumentException&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Passed API version does not exist."&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
      &lt;span class="o"&gt;}&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;apiMap&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="o"&gt;)();&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Usage:
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;  &lt;span class="c1"&gt;// assuming there is a config somewhere&lt;/span&gt;
  &lt;span class="no"&gt;API&lt;/span&gt; &lt;span class="n"&gt;apiv1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;APIFactory&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;getApiInstance&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Conclusion:
&lt;/h3&gt;

&lt;p&gt;So erm, yeah. Not perfect but perhaps a step in the right direction.&lt;/p&gt;

</description>
      <category>practice</category>
      <category>designpatterns</category>
    </item>
    <item>
      <title>Hi, I'm Daniel Mwakanema</title>
      <dc:creator>Daniel Mwakanema</dc:creator>
      <pubDate>Mon, 10 Apr 2017 08:22:33 +0000</pubDate>
      <link>https://forem.com/danielmwakanema/hi-im-daniel-mwakanema</link>
      <guid>https://forem.com/danielmwakanema/hi-im-daniel-mwakanema</guid>
      <description>&lt;p&gt;Hello there, I am currently a code monkey in the industry focused on becoming an intermediate beginner.&lt;/p&gt;

&lt;p&gt;I love JavaScript but also dabble in Ruby and PHP. My Git dwells here, &lt;a href="https://github.com/danielmwakanema" rel="noopener noreferrer"&gt;Daniel Mwakanema&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I am currently learning Go and advanced JavaScript.&lt;/p&gt;

&lt;p&gt;As you were.&lt;/p&gt;

</description>
      <category>introduction</category>
    </item>
  </channel>
</rss>
