<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Programming on Techformist</title>
    <link>https://techformist.com/tags/programming/</link>
    <description>Recent content in Programming on Techformist</description>
    <image>
      <url>https://techformist.com/logo.svg</url>
      <link>https://techformist.com/logo.svg</link>
    </image>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Wed, 15 Jan 2020 15:30:00 +0000</lastBuildDate><atom:link href="https://techformist.com/tags/programming/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>A story of company case studies and API testing</title>
      <link>https://techformist.com/2020/01/15/a-story-of-company-case-studies-and-api-testing/</link>
      <pubDate>Wed, 15 Jan 2020 15:30:00 +0000</pubDate>
      
      <guid>https://techformist.com/2020/01/15/a-story-of-company-case-studies-and-api-testing/</guid>
      <description>&lt;p&gt;#rant that none asked for.&lt;/p&gt;
&lt;p&gt;I came across this whitepaper on testing micro services. I clicked on &lt;a href=&#34;https://www.infosys.com/services/validation-solutions/case-studies/microservices-testing.html&#34;&gt;this link&lt;/a&gt; because I am writing microservices now but I am fairly new to microservices.&lt;/p&gt;
&lt;p&gt;I did a mistake that I have repeated 1593 times in the past. The said link was a resource by one of the big IT service providers.&lt;/p&gt;
&lt;p&gt;While the work indeed is commendable - automating 4000 test cases is no joke, the content and approach for highlighting the &amp;ldquo;best practice&amp;rdquo; leave much to be desired.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>#rant that none asked for.</p>
<p>I came across this whitepaper on testing micro services. I clicked on <a href="https://www.infosys.com/services/validation-solutions/case-studies/microservices-testing.html">this link</a> because I am writing microservices now but I am fairly new to microservices.</p>
<p>I did a mistake that I have repeated 1593 times in the past. The said link was a resource by one of the big IT service providers.</p>
<p>While the work indeed is commendable - automating 4000 test cases is no joke, the content and approach for highlighting the &ldquo;best practice&rdquo; leave much to be desired.</p>
<p>The paper highlights practices that have been assumed to be best practices for a long time - and provides absolutely no information other than to say &ldquo;we did so and so&rdquo;. &ldquo;Extreme automation&rdquo; is the buzzword of the day, and as we, of the corporate types, agree - it doesn&rsquo;t get better than that.</p>
<p>I mean - yes, I understand this is a mere case study. I don&rsquo;t expect every case study or paper to contain all the real &ldquo;stuff&rdquo; all the time, but following would have been welcome -</p>
<ol>
<li>How does the accelerator fare as compared to commercial tools today?</li>
</ol>
<ul>
<li>Savings in license costs by avoiding commercial tools (typically clients don&rsquo;t pay or think they don&rsquo;t pay for &ldquo;accelerators&rdquo;)</li>
<li>How well did the accelerator write tests? What was the coverage advantage vis-a-vis other tools</li>
<li>How did developers breathe easy by using this tool as compared to say writing tests in Postman (Pro), or using other open source and free tools that are popular today</li>
</ul>
<ol>
<li>By how much did the framework improve efficiency in generating data?</li>
<li>How was a high degree of overlap achieved in smart sharing of regression/system test cases, while keeping effort and test duration minimal</li>
</ol>
<p>Take note that I have still not outlined just how I am doing the &ldquo;thing&rdquo;. That may be part of the IP, or reflect my &ldquo;scarcity mindset&rdquo;. But, readers only get excited about the work when they know more about the advantages of tools and practices employed in the project.</p>
<p>A more complete paper would probably also cover -</p>
<ol>
<li>Employing live vs. test data, and how the framework can help in specific cases. How we found advantage in one or both?</li>
<li>How performance tests play a greater role today? How can they be integrated in the overall cycle? How are they automated using existing toolsets?</li>
<li>How well can we mock or virtualise services more efficiently given a specific set of constraints?</li>
</ol>
<h1 id="its-not-all-bad">It&rsquo;s not all bad</h1>
<p>Don&rsquo;t get me wrong. I can understand where the above content is coming from. Marketing pressures, typical development processes not covering best practices, and lack of resources to think about content strategy through and through - they are all real.</p>
<p>And.. I have been there multiple times. I have been guilty of providing such content, case studies and &ldquo;white papers&rdquo; in the past (and probably churn that out again?) - content that lacks substance for so called &ldquo;expert readers&rdquo; but content nevertheless. I hope the servers hosting them will burn to ground so that I can lecture on best practices of writing good content. Oh wait, I hope it does not include this website too.</p>
<p>Fortunately, good content is everywhere today. Want to automate your API testing and write something about it? I would say start from these posts -</p>
<ul>
<li>know what API testing is about - <a href="https://martinfowler.com/articles/microservice-testing/#agenda">https://martinfowler.com/articles/microservice-testing/#agenda</a></li>
<li>free and open source tools - <a href="https://swagger.io/tools/open-source/open-source-integrations/">Integrations of swagger with open source tools</a> including <a href="https://github.com/Maks3w/SwaggerAssertions">SwaggerAssertions</a>, <a href="https://www.npmjs.com/package/swagger-test">swagger-test</a></li>
<li>how a popular tool aids writing your tests - look up Postman Pro</li>
<li>how a seemingly successful product helps test automation - <a href="https://assertible.com/blog/testing-an-api-using-swagger">https://assertible.com/blog/testing-an-api-using-swagger</a></li>
</ul>
]]></content:encoded>
    </item>
    
    <item>
      <title>Production to test migration strategy</title>
      <link>https://techformist.com/production-test-migration-strategy/</link>
      <pubDate>Sun, 08 Sep 2019 06:30:00 +0000</pubDate>
      
      <guid>https://techformist.com/production-test-migration-strategy/</guid>
      <description>&lt;p&gt;While we love to have production-like environments for user testing, managing data and the test environments can present unique challenges.&lt;/p&gt;
&lt;p&gt;In today&amp;rsquo;s enterprises it is fairly common to have multiple test environments including staging, system / user testing environments and so on. These environments expect production-like features but only for specified users.&lt;/p&gt;
&lt;p&gt;For example -&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Validations have to work as they are in production&lt;/li&gt;
&lt;li&gt;Document templates and document merge has to work&lt;/li&gt;
&lt;li&gt;Email and SMS communications have to work for select users&lt;/li&gt;
&lt;li&gt;Logins have to work for select users&lt;/li&gt;
&lt;li&gt;A few staging environments may need data in volume - what better data can you find outside of your own production environment?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;As is the norm for typical enterprise applications, I tend to -&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>While we love to have production-like environments for user testing, managing data and the test environments can present unique challenges.</p>
<p>In today&rsquo;s enterprises it is fairly common to have multiple test environments including staging, system / user testing environments and so on. These environments expect production-like features but only for specified users.</p>
<p>For example -</p>
<ol>
<li>Validations have to work as they are in production</li>
<li>Document templates and document merge has to work</li>
<li>Email and SMS communications have to work for select users</li>
<li>Logins have to work for select users</li>
<li>A few staging environments may need data in volume - what better data can you find outside of your own production environment?</li>
</ol>
<p>As is the norm for typical enterprise applications, I tend to -</p>
<ul>
<li>keep environments isolated</li>
<li>build environments on specific branches on demand</li>
<li>copy over whatever user configuration and user data that are relevant from production</li>
</ul>
<p>While our build scripts make the build process really easy, the last item for data presents a problem.</p>
<p>For one, we may have sensitive data that has no place in test environments. This data is not meant to be played around by developers, testers and test users.</p>
<p>The second problem is to isolate our real customers from whatever plight awaits their data in test environments. For example, what happens in test environments should stay in test environment, and is not visible/have zero impact on anyone who is not associated with testing.</p>
<p>I try to work-around the problem of data and configuration management post-migration by (trying to) maintain and deploy a bunch of DB/server-side scripts to -</p>
<ol>
<li>Change sensitive fields like emails, and phone numbers</li>
<li>Change encryption keys if required and dummify data in pre-identified fields like personal health information</li>
<li>Scramble logins and passwords to something different</li>
</ol>
<p>All this and more is done post data &amp; configuration migration to target environments.</p>
<p>While all the setup activities need to be automated and be part of test migration scripts, I have never really gotten to the nirvana stage here.</p>
<p>Most of the times I end up doing some manual work and stitch together bit and pieces to -</p>
<ul>
<li>migrate a part of a huge data-set with quirky data distribution requirements</li>
<li>migrate specific parts of production while merging that with parts from other environments</li>
</ul>
<p>I can blame anyone and everyone for that, but at the end of the day, problem lies in my own improper budgeting. Having a lean team (or I alone) focused on a particular solution or project does not help. While the limited people, time and budget gets the work done really quickly and efficiently, there are essentials such as migrations that move to a &lsquo;quasi-essentials&rsquo; bucket, and do not get the attention they deserve.</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>What is GraphQL and why should I use it?</title>
      <link>https://techformist.com/why-use-graphql/</link>
      <pubDate>Wed, 21 Aug 2019 06:30:00 +0000</pubDate>
      
      <guid>https://techformist.com/why-use-graphql/</guid>
      <description>&lt;p&gt;Why do I use GraphQL? Also, the case for not using GraphQL.&lt;/p&gt;
&lt;p&gt;You must have seen the previous post where I waxed eloquent about &lt;a href=&#34;https://techformist.com/not-designing-rest-services&#34;&gt;how I mess up my Rest APIs&lt;/a&gt;. There was no way I would be satisfied doing that to a single technology stack.&lt;/p&gt;
&lt;p&gt;Ergo, GraphQL.&lt;/p&gt;
&lt;h3 id=&#34;what-is-the-need-for-graphql&#34;&gt;What is the need for GraphQL?&lt;/h3&gt;
&lt;p&gt;&lt;a href=&#34;https://www.google.com/search?q=graphql&#34;&gt;Google GraphQL&lt;/a&gt; and refer &lt;a href=&#34;https://graphql.org/learn/&#34;&gt;docs&lt;/a&gt;- there are smarter people with better answers than me.&lt;/p&gt;
&lt;p&gt;But, since the Internet can be a scary place and I love to write about things that I am not an expert in - here&amp;rsquo;s a gist about what I think.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>Why do I use GraphQL? Also, the case for not using GraphQL.</p>
<p>You must have seen the previous post where I waxed eloquent about <a href="/not-designing-rest-services">how I mess up my Rest APIs</a>. There was no way I would be satisfied doing that to a single technology stack.</p>
<p>Ergo, GraphQL.</p>
<h3 id="what-is-the-need-for-graphql">What is the need for GraphQL?</h3>
<p><a href="https://www.google.com/search?q=graphql">Google GraphQL</a> and refer <a href="https://graphql.org/learn/">docs</a>- there are smarter people with better answers than me.</p>
<p>But, since the Internet can be a scary place and I love to write about things that I am not an expert in - here&rsquo;s a gist about what I think.</p>
<p>Back to the story..</p>
<blockquote>
<p>GraphQL is the SQL for APIs.</p>
</blockquote>
<p>Before you say .. &lsquo;ah.. I now know everything!&rsquo;, read on.</p>
<p>You see - most of the transactions on the web involve fetching some data or the other.</p>
<p>Clients need to be authenticated, authorised and then request data for those transactions to happen. Servers, which supply the data, will comply with client requests based on pre-defined rules.</p>
<p>Rest is an architectural style that allows you to standardize and streamline client-server requests. You can control resources (accounts, contacts etc.) and the operations (GET, STORE etc.).</p>
<p>So far so good. You may even <em>think</em> that you reached a Nirvana state with what has been described so far, but imagine what would happen if you start a series of requests -</p>
<pre tabindex="0"><code>You: Give me contacts
Server: Here are 100 contacts with 501 fields per contact

You: Give me contacts and activities for each contact
Server: Here are 1000 contacts and 1 million activities per contact

You: Give me contact detail
Server: Here you go - 1000 fields of the contact
You: Give me address for same contact
Server: Oh God, you again? Here&#39;s the address. And, can you please stop this madness?
</code></pre><p>You will see such examples in the real world - the problems described are referred as &lsquo;over-fetching&rsquo; (getting more data than I need) and &lsquo;under-fetching&rsquo; (getting less data than I need).</p>
<p>The properties of over-fetching -</p>
<ul>
<li>server fetches more data from database (or may query for related entities that are not always required)</li>
<li>more data is pushed through the pipe</li>
<li>client gets more data than required and has to process data to selectively pick and display data.</li>
</ul>
<p>And, those for under-fetching -</p>
<ul>
<li>client does not require all data in one-go, requests for related entities or fields</li>
<li>additional network requests and more needless traffic</li>
<li>more time to render UI with complete data</li>
</ul>
<p>The back &amp; forth between server and client frustrates the server - as seen in above conversation, and more importantly, impacts client-side performance.</p>
<p>The multiple back and forth requests make Rest &ldquo;chatty&rdquo;.</p>
<p>Ergo, GraphQL.</p>
<p>(I assure you - Matrix has very little to do with me using &rsquo;ergo&rsquo; all the time.)</p>
<h3 id="really-why-do-i-use-graphql">Really, why do <em>I</em> use GraphQL?</h3>
<p><em>I</em> certainly do not use GraphQL because it -</p>
<ul>
<li>is the in-thing in web development today</li>
<li>is revered by everyone who say there is nothing more wonderful</li>
<li>is typed, and that makes it so magical</li>
<li>provides a really good looking IDE that makes it so easy to develop the queries</li>
<li>makes services so easy to code (all it needs is a gesture and all the little thingies arrange themselves in perfect harmony)</li>
<li>drastically reduces chatty network traffic and improves the speed to &lsquo;burn rubber&rsquo; levels even before ignition is turned on</li>
<li>uses in-built security rules that makes it so easy to provide role-based authorization</li>
<li>is loved equally by server and client tech stacks</li>
<li>specifies a good abstraction layer for databases</li>
<li>has subscriptions and those are so so amazing</li>
<li>is developed by Facebook. I happen to adore Zuckerberg</li>
</ul>
<p>Or, I may be using GraphQL for a couple of points mentioned above and that is embarrassing to admit (or downright stupid).</p>
<p>The primary reasons for me to use GraphQL are -</p>
<ul>
<li>it reduces work on the server-side (surprise, surprise!?). I do not have to write APIs for each and every request, or over-engineer APIs imagining all possible scenarios. Since most of my services are data-heavy, I particularly like the fact that I don&rsquo;t need to maintain a dozen end-points</li>
<li>development iterations are easier on client. I can make adjustments to client code to fetch more or less data</li>
<li>pass only the required data b/w client and server</li>
</ul>
<p>But, on the other hand -</p>
<ul>
<li>GraphQL makes it harder to code server-side services (that is just me, not the fault of GraphQL per se).</li>
<li>I also find it harder to control the queries that clients request while they snicker in the background (the developers of the said client, not client-users. Since I am the only developer in many of my applications, I snicker to myself about myself. I need help!).</li>
</ul>
<p>I find it easier to just enable standard Rest pattern to start with (scaffolded most of the time). Then, I start enabling GraphQL services for specific transactions and go from there.</p>
<h3 id="err-what-are-you-even-talking-about">Err.. what are you even talking about?</h3>
<p>Let&rsquo;s see a few examples.</p>
<p>If I need to get a specific contact, I would do the following transaction in REST -</p>
<pre tabindex="0"><code>GET https://api.com/contact
</code></pre><p>The response will be -</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-js" data-lang="js"><span class="line"><span class="cl"><span class="nx">data</span><span class="o">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">  <span class="nx">contacts</span><span class="o">:</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl">    <span class="p">{</span>
</span></span><span class="line"><span class="cl">      <span class="nx">planet</span><span class="o">:</span> <span class="s2">&#34;earth&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">      <span class="nx">name</span><span class="o">:</span> <span class="s2">&#34;Rama&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">      <span class="nx">age</span><span class="o">:</span> <span class="mi">42</span>
</span></span><span class="line"><span class="cl">    <span class="p">},</span>
</span></span><span class="line"><span class="cl">    <span class="p">{</span>
</span></span><span class="line"><span class="cl">      <span class="nx">planet</span><span class="o">:</span> <span class="s2">&#34;mercury&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">      <span class="nx">name</span><span class="o">:</span> <span class="s2">&#34;Kris&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">      <span class="nx">age</span><span class="o">:</span> <span class="mi">21</span>
</span></span><span class="line"><span class="cl">    <span class="p">},</span>
</span></span><span class="line"><span class="cl">    <span class="p">{</span>
</span></span><span class="line"><span class="cl">      <span class="nx">planet</span><span class="o">:</span> <span class="s2">&#34;mars&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">      <span class="nx">name</span><span class="o">:</span> <span class="s2">&#34;Joe&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">      <span class="nx">age</span><span class="o">:</span> <span class="mi">63</span>
</span></span><span class="line"><span class="cl">    <span class="p">}</span>
</span></span><span class="line"><span class="cl">  <span class="p">];</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></div><p>I can do the following in GraphQL and send it as a POST request to server -</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-graphql" data-lang="graphql"><span class="line"><span class="cl"><span class="kd">query</span><span class="w"> </span><span class="p">{</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nc">contacts</span><span class="p">(</span><span class="py">name</span><span class="p">:</span><span class="w"> </span><span class="s">&#34;Rama&#34;</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nc">name</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="py">age</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="p">}</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="p">}</span><span class="w">
</span></span></span></code></pre></div><p>The response will be like so -</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-js" data-lang="js"><span class="line"><span class="cl"><span class="nx">data</span><span class="o">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">  <span class="nx">contacts</span><span class="o">:</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl">    <span class="p">{</span>
</span></span><span class="line"><span class="cl">      <span class="nx">name</span><span class="o">:</span> <span class="s2">&#34;Rama&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">      <span class="nx">age</span><span class="o">:</span> <span class="mi">42</span>
</span></span><span class="line"><span class="cl">    <span class="p">}</span>
</span></span><span class="line"><span class="cl">  <span class="p">];</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></div><p>The responses in the two transactions speak for themselves!</p>
<h3 id="what-are-graphql-operations-and-why-should-i-care">What are GraphQL operations? And, why should I care?</h3>
<p>No matter what we do in the client-server world - we are trying to do one simple thing -</p>
<blockquote>
<p>Share data and business logic b/w server and client</p>
</blockquote>
<p>One can query, insert, update or delete data and can initiate those transactions from client. This can either happen -</p>
<ul>
<li>with the server not caring about the &ldquo;state&rdquo; of the client. i.e., client sends request (with authentication incl. as part of request if required), and server answers the call</li>
<li>server keeps client interests in mind, has an open channel with the client, and keeps track of data so that clients get changes as they happen</li>
</ul>
<p>GraphQL builds a layer on top of a database to assist you to transmit data in both cases.</p>
<h5 id="query">Query</h5>
<p>GraphQL queries help you to fetch only the records and attributes you need - we have seen examples earlier.</p>
<p>You can also include different entities (think &rsquo;tables&rsquo; as an analogy) in the request. Use GraphQL to fetch records with specified relationships, rather than making separate requests for distinct entities.</p>
<h5 id="mutation">Mutation</h5>
<p>GraphQL mutations are used to insert/change data.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-graphql" data-lang="graphql"><span class="line"><span class="cl"><span class="kd">mutation</span><span class="w"> </span><span class="nc">createContact</span><span class="w"> </span><span class="p">{</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="py">addContact</span><span class="p">(</span><span class="py">name</span><span class="p">:</span><span class="w"> </span><span class="s">&#34;Joe&#34;</span><span class="p">,</span><span class="w"> </span><span class="nc">age</span><span class="p">:</span><span class="w"> </span><span class="nc">100</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="py">id</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="p">}</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="p">}</span><span class="w">
</span></span></span></code></pre></div><p>The above query provides instruction to use a mutation called <code>createContact</code> that in turn uses <code>addContact</code> to add a contact record with name <code>Joe</code> and age <code>100</code>.</p>
<h5 id="subscription">Subscription</h5>
<p>Subscriptions establish a channel between server and client. Clients can subscribe to record updates and get notified (through a simple notification, or by actual &lsquo;push&rsquo; of the data from server) whenever there are changes.</p>
<p>Subscriptions use &lsquo;web sockets&rsquo; under the hood. This is a battle-tested piece of technology that enables real-time data updates to client.</p>
<p>For example - clients can use the below subscription to get the list of contacts who won the lottery.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-graphql" data-lang="graphql"><span class="line"><span class="cl"><span class="kd">subscription</span><span class="w"> </span><span class="nc">listenWonLottery</span><span class="w"> </span><span class="p">{</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="py">wonLottery</span><span class="w"> </span><span class="p">{</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="py">name</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="py">deals</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="p">}</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="p">}</span><span class="w">
</span></span></span></code></pre></div><p>Let&rsquo;s see the flow -</p>
<ol>
<li>Clients subscribe to contacts</li>
<li>One or more of the contacts get updated in the database when they win lottery</li>
<li>On database update, a notification gets triggered to clients</li>
<li>The notification contains contact&rsquo;s name and deals associated with contact</li>
<li>Client can thereon show a popup with contact name and show flying balloons for effect</li>
</ol>
<h3 id="what-are-the-different-components-required-to-implement-graphql">What are the different components required to implement GraphQL?</h3>
<p>GraphQL is just the language for API and runtime for executing them queries. It is not hardwired to database and does not specify how the database operations need to be executed.</p>
<p>The different components that implement GraphQL stack are below. These components are not part of GraphQL specifications but are just part of the stack that support transactions using GraphQL.</p>
<h5 id="server">Server</h5>
<p>The implementation/tech stack decides how GraphQL is incorporated in the transaction. Server receives GraphQL requests from clients, establishes connection to database, converts graph queries to a language understood by database, fetches results and sends the responses back to clients.</p>
<p>A server may also include the functions expected from a &ldquo;normal&rdquo; server -</p>
<ul>
<li>apply business logic to data</li>
<li>listen to supported types of requests on specified network ports</li>
<li>takes care of all the supporting infrastructure required to serve requests to clients.</li>
</ul>
<h5 id="database">Database</h5>
<p>Stores data and maintains atomicity, consistency etc. etc. for data. It is a glorified file system that supports individual transactions and does not mess up the data just because the network went kaput, or your client decided to play a game.</p>
<h5 id="client">Client</h5>
<p>Can be a browser, mobile app or anything that requests data from server and consumes server response to do &ldquo;something&rdquo;. We create GraphQL queries, mutations etc. and send them over in a simple POST request.</p>
<h3 id="what-are-the-terms-that-i-should-be-familiar-about">What are the terms that I should be familiar about?</h3>
<h5 id="schema">Schema</h5>
<p>A schema is the building block of GraphQL. It is described using a language that we can understand - it can be any language, but a simple option aptly named &ldquo;Schema Definition Language&rdquo; is used in the standard implementation.</p>
<p>Consider the below example -</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-graphql" data-lang="graphql"><span class="line"><span class="cl"><span class="kd">type</span><span class="w"> </span><span class="nc">Contact</span><span class="w"> </span><span class="p">{</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="py">name</span><span class="p">:</span><span class="w"> </span><span class="nc">String</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="py">deal</span><span class="p">:</span><span class="w"> </span><span class="nc">Deal</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="p">}</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="kd">type</span><span class="w"> </span><span class="nc">Deal</span><span class="w"> </span><span class="p">{</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="py">description</span><span class="p">:</span><span class="w"> </span><span class="nc">String</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="py">value</span><span class="p">:</span><span class="w"> </span><span class="nc">String</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="p">}</span><span class="w">
</span></span></span></code></pre></div><p>The schema definition helps a client-side developer to see and understand the relationships b/w data entities, and thereon construct a GraphQL query.</p>
<h5 id="resolvers">Resolvers</h5>
<p>A resolver is a function that returns data in the shape specified by schema.</p>
<p>For e.g. -</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-js" data-lang="js"><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">resolvers</span> <span class="o">=</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">  <span class="nx">Query</span><span class="o">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="nx">contact</span><span class="p">(</span><span class="nx">root</span><span class="p">,</span> <span class="nx">args</span><span class="p">)</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">      <span class="k">return</span> <span class="nx">contacts</span><span class="p">.</span><span class="nx">filter</span><span class="p">(</span><span class="nx">contact</span> <span class="p">=&gt;</span> <span class="nx">contact</span><span class="p">.</span><span class="nx">id</span> <span class="o">===</span> <span class="nx">args</span><span class="p">.</span><span class="nx">id</span><span class="p">)[</span><span class="mi">0</span><span class="p">];</span>
</span></span><span class="line"><span class="cl">    <span class="p">},</span>
</span></span><span class="line"><span class="cl">    <span class="nx">deals</span><span class="p">(</span><span class="nx">root</span><span class="p">,</span> <span class="nx">args</span><span class="p">)</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">      <span class="k">return</span> <span class="nx">deals</span><span class="p">.</span><span class="nx">filter</span><span class="p">(</span><span class="nx">deal</span> <span class="p">=&gt;</span> <span class="nx">deal</span><span class="p">.</span><span class="nx">id</span> <span class="o">===</span> <span class="nx">args</span><span class="p">.</span><span class="nx">id</span><span class="p">)[</span><span class="mi">0</span><span class="p">];</span>
</span></span><span class="line"><span class="cl">    <span class="p">}</span>
</span></span><span class="line"><span class="cl">  <span class="p">},</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">  <span class="nx">Contact</span><span class="o">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="nx">deals</span><span class="o">:</span> <span class="nx">contact</span> <span class="p">=&gt;</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">      <span class="k">return</span> <span class="nx">deals</span><span class="p">.</span><span class="nx">filter</span><span class="p">(</span><span class="nx">deal</span> <span class="p">=&gt;</span> <span class="nx">deal</span><span class="p">.</span><span class="nx">contactId</span> <span class="o">===</span> <span class="nx">contact</span><span class="p">.</span><span class="nx">id</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">    <span class="p">}</span>
</span></span><span class="line"><span class="cl">  <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">};</span>
</span></span></code></pre></div><p>We use a resolver to write queries, mutations and subscriptions.</p>
<h5 id="object-type--fields">Object type / fields</h5>
<p>In the GraphQL query outlined above -</p>
<ul>
<li>Object type is &lsquo;Contact&rsquo; and &lsquo;Deal&rsquo;</li>
<li>Fields are <code>name</code>, <code>description</code>, and <code>value</code></li>
</ul>
<h3 id="this-is-so-cool-that-i-slept-through-the-article-give-it-to-me-straight---should-i-use-graphql">This is so cool that I slept through the article. Give it to me straight - should I use GraphQL?</h3>
<p>Not everywhere.</p>
<p>Use GraphQL when you need to fetch a lot of data having varying shapes / many relationships. Use GraphQL to simplify the data passed between client and server.</p>
<p>At the same time -</p>
<ol>
<li>Remember that plain Rest API implementations are simpler</li>
<li>Even in data-heavy applications, I do not see a big advantage of applying GraphQL everywhere (except architectural uniformity/ standardization, maybe). For e.g. if you have narrow relationships between entities that do not require related data views all the time</li>
<li>Keep track of how clients use GraphQL - crazy queries can lead to performance issues</li>
</ol>
<p>Why do I find Rest services simpler?</p>
<ol>
<li>Endpoint setup is simple on the server. Expose an API or two, and use an ORM to fetch/update data in one or two steps - no sight of fields and related entities anywhere unless you want to deal with them</li>
<li>In addition to the previous point, or supplementing it, is the fact that the tooling is amazing - the technology is so old and supported so well that most of the time it just requires a couple of clicks (or lines of code) to fully set up</li>
<li>I control queries in the back-end - easier control on who accesses the data and how. I also find it easier to solve potential performance issues since I control filters and sort on the server</li>
<li>But all said and done, I may be finding Rest easier since I have spent so much time with it :)</li>
</ol>
<h3 id="ok-i-am-in-where-should-i-start">Ok, I am in. Where should I start?</h3>
<p>I find the following technology stacks easy to follow and useful to learn for the long run. The recommendations are skewed towards Vue since I use Vue all the time and strongly believe that Vue is easier on beginners.</p>
<h5 id="enable-graphql-server-side">Enable GraphQL server-side</h5>
<p>It is a good idea to create a server on your own and see GraphQL flow in the back-end for real.</p>
<table>
  <thead>
      <tr>
          <th>Category</th>
          <th>Recommended</th>
          <th>Remarks</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>I know SQL and understand DBs</td>
          <td><a href="https://www.graphile.org/postgraphile/">PostGraphile</a></td>
          <td>Refer <a href="/spin-up-your-own-local-graphql-server-within-15-min/">this</a></td>
      </tr>
      <tr>
          <td>I want to learn more of serverless</td>
          <td><a href="https://aws.amazon.com/appsync/">AppSync</a></td>
          <td>Sign up for 1-year limited free servers on Amazon AppSync</td>
      </tr>
      <tr>
          <td>I want to learn GraphQL using a CMS</td>
          <td><a href="https://strapi.io/">StrapiJS</a></td>
          <td>In beta, but good for production</td>
      </tr>
      <tr>
          <td>I want to experiment with static sites + GraphQL</td>
          <td><a href="https://gridsome.org/">Gridsome</a></td>
          <td>New, but promising.</td>
      </tr>
      <tr>
          <td>I know PHP</td>
          <td>Laravel + <a href="https://lighthouse-php.com/">Lighthouse</a></td>
          <td></td>
      </tr>
      <tr>
          <td>I am looking forward to a long-term relationship</td>
          <td><a href="https://nestjs.com/">NestJS</a></td>
          <td>Good server capabilities + good GraphQL support</td>
      </tr>
      <tr>
          <td>I am a master</td>
          <td>Guide me towards enlightenment, maybe</td>
          <td>What are you even doing here?</td>
      </tr>
  </tbody>
</table>
<h5 id="use-graphql-on-the-client">Use GraphQL on the client</h5>
<ul>
<li><a href="https://vuejs.org">Vue</a> + <a href="https://github.com/Akryum/vue-apollo">Vue-Apollo</a></li>
<li><a href="https://svelte.dev/">Svelte</a> + <a href="https://github.com/apollographql/apollo-client/tree/master/packages/apollo-boost">Apollo</a>.</li>
</ul>
<p>Also see: <a href="/create-a-simple-to-do-app-using-svelte-and-graphql/">create a simple to-do with Svelte + GraphQL</a></p>
<h3 id="finis">Finis</h3>
<p>It ends here :)</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>How not to design Rest services</title>
      <link>https://techformist.com/not-designing-rest-services/</link>
      <pubDate>Tue, 20 Aug 2019 06:30:00 +0000</pubDate>
      
      <guid>https://techformist.com/not-designing-rest-services/</guid>
      <description>&lt;p&gt;How not to design Rest services?&lt;/p&gt;
&lt;p&gt;This is not a theoritical introduction to Rest - there&amp;rsquo;s something called the &amp;lsquo;Great Internet&amp;rsquo; for that. But, what I do want to (cautiously) write about is how I mess up the design principles carefully laid out by smarter people.&lt;/p&gt;
&lt;h3 id=&#34;practice-1-use-verbs-in-resource-names&#34;&gt;Practice 1: Use verbs in resource names&lt;/h3&gt;
&lt;p&gt;We typically use the following API names -&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;GET https://api.com/contact
PATCH https://api.com/contact
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This is not a problem in the normal course of designing services. But, when it is time to get some complex queries - I always do a rain dance and come up with stupid names.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>How not to design Rest services?</p>
<p>This is not a theoritical introduction to Rest - there&rsquo;s something called the &lsquo;Great Internet&rsquo; for that. But, what I do want to (cautiously) write about is how I mess up the design principles carefully laid out by smarter people.</p>
<h3 id="practice-1-use-verbs-in-resource-names">Practice 1: Use verbs in resource names</h3>
<p>We typically use the following API names -</p>
<pre tabindex="0"><code>GET https://api.com/contact
PATCH https://api.com/contact
</code></pre><p>This is not a problem in the normal course of designing services. But, when it is time to get some complex queries - I always do a rain dance and come up with stupid names.</p>
<pre tabindex="0"><code>GET https://api.com/getAccountSalesActivitySummaryForMonth
</code></pre><p><strong>Best practice</strong></p>
<ul>
<li>do not use verbs, use nouns</li>
<li>represent the resource in the name (if there is more than one resource, pick your favourite)</li>
<li>use simple URLs</li>
</ul>
<h3 id="practice-2-patterns-that-no-one-understands">Practice 2: Patterns that no one understands</h3>
<p>APIs like below are partly descriptive but make it difficult to maintain consistency in naming conventions.</p>
<pre tabindex="0"><code>GET https://api.com/getAccountSalesActivitySummaryForMonth
POST https://api.com/createMaintenanceActivitiesForQuarter
PUT https://api.com/updateAssignmentForDay
</code></pre><p><strong>Best practice</strong></p>
<ul>
<li>already covered in the previous best practice ( I had a brain freeze while starting practice 2 )</li>
</ul>
<h3 id="practice-3-use-param-in-place-of-a-proper-uri">Practice 3: Use param in place of a proper URI</h3>
<p>If I need a specific activity for a contact -</p>
<pre tabindex="0"><code>GET https://api.com/activities/?q={contactId=&#39;1-ABC&#39;}
</code></pre><p>Why do this? Well, I can reuse services on the server side and write same services to -</p>
<ul>
<li>bring in the activities for the particular contact (or)</li>
<li>for any of the thousand queries that a client throws at me.</li>
</ul>
<p>The practice of using ids as queries is not &ldquo;standard&rdquo; and not clearly understood by everyone. I live in constant fear of the maintenance guy ringing my doorbell.</p>
<p><strong>Best practice</strong></p>
<p>The following is most often seen to fetch related records.</p>
<pre tabindex="0"><code>GET https://api.com/contact/1-ABC/activities
</code></pre><h3 id="practice-4-use-patch-and-put-interchangeably">Practice 4: Use PATCH and PUT interchangeably</h3>
<p>I tend to use -</p>
<ol>
<li>Use PATCH if you are incrementally updating the record</li>
<li>Use PUT when you want the new record to completely update the previous record - lock, stock and without id (may be?)</li>
</ol>
<p>But, I have not strictly adhered to the said practice.</p>
<p>There are many who disagree with the PUT/PATCH argument and have been waging a war about where to use what.</p>
<p><strong>Best practice</strong></p>
<p>Follow the above method or otherwise. But, just follow ONE way of doing things.</p>
<p>If you are working in ASP.NET that scaffolds PUT even for a PATCH - get prepared for end of the world. Change the scaffolding or change the tech stack.</p>
<h3 id="practice-5-create-distinct-apis-for-role-based-filters">Practice 5: Create distinct APIs for role-based filters</h3>
<p>I don&rsquo;t quite know when I started this bizarre practice.</p>
<p>Let say I have to filter data to address the below requirements -</p>
<ol>
<li>A rep should see her records</li>
<li>A manager should see her records and her reps&rsquo; records</li>
<li>A CEO should see no records until the company gets bankrupt</li>
</ol>
<p>I create three APIs -</p>
<pre tabindex="0"><code>GET https://api.com/my-deal/
GET https://api.com/mgr-deal/
GET https://api.com/no-deal/
</code></pre><p>Internally these fetch data from the same service (<code>getDealsForRole</code>), but only after setting the appropriate filters.</p>
<p>Why do that? I find it easier to manage security and filters in controller/services rather than routes. The resources also are self-contained to manage errors, and can apply complex filter criteria to client-calls or calls from other services (e.g. manager should see reps&rsquo; deals but not her private activities).</p>
<p>The problem of applying role-based filters is easily done by using a standard ACL or even by introducing filters, but not all tech stacks have standard ACLs and the damage has already been done for quite a few applications.</p>
<p><strong>Best practice</strong></p>
<ul>
<li>Use standard ACLs - if your tech stack supports it. Else, pray and use below alternatives.</li>
<li>Apply security at the gate and this is at the route-level.</li>
<li>You could also develop ACL such that the filters get applied without service explicitly requesting for it</li>
</ul>
<h3 id="practice-6-stuff-response-with-everything-you-may-not-get-a-second-chance">Practice 6: Stuff response with everything, you may not get a second chance</h3>
<p>My typical service gets to serve related records along with the main entity.</p>
<p>For e.g. -</p>
<pre tabindex="0"><code>GET https://api.com/account
</code></pre><p>The account request may be stuffed to fetch account, account&rsquo;s contacts and deals.</p>
<p>Normally I would avoid fetching all the data that the client did not request for, but I just hate to do too many requests to server. Without all the data, the client has to fetch -</p>
<ul>
<li>list of records</li>
<li>optionally the detail record at some point of time</li>
<li>related records</li>
</ul>
<p>Rather than see the streamlined &ldquo;fetch&rdquo;, I include contacts and deals along with the account request. And, before becoming fully aware of what I did - I start throwing queries at database that use some weird joins to fetch all kinds of records everywhere.</p>
<ul>
<li>Close coupling of client-server is a problem if you have to serve multiple types of clients. Should never be used for public services</li>
<li>will reduce traffic but increases payload</li>
<li>sooner of later I will design a &ldquo;simpler&rdquo; service since the main service took so long to fetch results (and the madness continues)</li>
</ul>
<p><strong>Best practice</strong></p>
<p>Keep your services contained and don&rsquo;t let them go crazy.</p>
<p>There is nothing wrong in firing a query to get details (they are separate components anyway).</p>
<h3 id="finis">Finis</h3>
<p>I will stop here.</p>
<p>Not because I don&rsquo;t know what other mistakes I make. It is just that I realized how little I know after going through this post more than once.</p>
<p>It is probably time for me to hit that refresh button. I am switching to RPC y&rsquo;all.</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Business layer vs. direct database operations</title>
      <link>https://techformist.com/business-layer-direct-database-operations/</link>
      <pubDate>Sun, 24 Mar 2019 06:30:00 +0000</pubDate>
      
      <guid>https://techformist.com/business-layer-direct-database-operations/</guid>
      <description>&lt;p&gt;I have this annoying behaviour to force as many things as I can through the business layer. This can be a boon and bane at the same time.&lt;/p&gt;
&lt;h5 id=&#34;what-do-i-mean-by-business-layer&#34;&gt;What do I mean by business layer?&lt;/h5&gt;
&lt;p&gt;Let&amp;rsquo;s say I have an application running on AdonisJS. For every operation (CRUD) -&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I try to go through controllers/services&lt;/li&gt;
&lt;li&gt;Almost all of them through APIs when called from front-end&lt;/li&gt;
&lt;li&gt;Almost all of the operations through Lucid with exceptions through Database statements&lt;/li&gt;
&lt;li&gt;Use Tasks or equivalent for batches&lt;/li&gt;
&lt;/ul&gt;
&lt;h5 id=&#34;everyone-does-this-why-is-it-a-point-of-discussion&#34;&gt;Everyone does this, why is it a point of discussion?&lt;/h5&gt;
&lt;p&gt;Going through business layer is good. You can control what gets read or updated when routing through the server layers.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>I have this annoying behaviour to force as many things as I can through the business layer. This can be a boon and bane at the same time.</p>
<h5 id="what-do-i-mean-by-business-layer">What do I mean by business layer?</h5>
<p>Let&rsquo;s say I have an application running on AdonisJS. For every operation (CRUD) -</p>
<ul>
<li>I try to go through controllers/services</li>
<li>Almost all of them through APIs when called from front-end</li>
<li>Almost all of the operations through Lucid with exceptions through Database statements</li>
<li>Use Tasks or equivalent for batches</li>
</ul>
<h5 id="everyone-does-this-why-is-it-a-point-of-discussion">Everyone does this, why is it a point of discussion?</h5>
<p>Going through business layer is good. You can control what gets read or updated when routing through the server layers.</p>
<p>For me personally, the use of business layer has been a cult-like thing.</p>
<p>You see - I had a long history with off-the-shelf applications. These applications foster cult-like behaviour when it comes to database updates. There are far too many things that can break an application for no reason, and the trust on some of the sensitive data (e.g. audit trails) can go for a toss when data updates are not handled responsibly.</p>
<h5 id="pros--cons">Pros / cons</h5>
<p>Using business layer enforces good behaviour -</p>
<ul>
<li>Follow consistent business rules</li>
<li>Maintain data sanctity</li>
<li>Easier to change and maintain (well, this is subjective)</li>
<li>Easier to do a knowledge transfer to others in the team. Everyone is standardized on business layer :)</li>
</ul>
<p>In smaller applications that I have been developing outside of my main line of work - this can mean -</p>
<ul>
<li>Large scale updates / operations can be a pain - going through layers not optimized for the job can cause memory leaks that had never been found, severe performance issues</li>
<li>Batched operations are not always first-class citizens of an app (e.g. update hundred records in a batch to minimize database operations)</li>
<li>Complexity to the code-base when your back-end updates have to (ahem) skip a few rules</li>
</ul>
<p>In general: wrong tool for the job = conflicts with the larger world and self.</p>
<h5 id="what-to-do-when-i-am-in-such-a-pickle">What to do when I am in such a pickle?</h5>
<ul>
<li>Prefer business layer for &rsquo;normal&rsquo; operations. Scale the layer for dozens of operations in one go. Implement batch handling but do not go over-board (subjective and overboard definition varies as per your requirements)</li>
<li>Don&rsquo;t over-engineer your business layer to handle batch operations</li>
<li>Rely back on database operations or third party tools (e.g. an ETL)</li>
<li>Establish checks and balances for frequent third party operations (e.g. apply rules &amp; validate file before the actual update to the database, create automated tasks to review critical data flowing in from external applications)</li>
</ul>
<h5 id="i-still-do-not-understand-the-problem">I still do not understand the problem</h5>
<p>Good for you. Get back to work.</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Universal Apps and MeteorJS in 2019</title>
      <link>https://techformist.com/universal-apps-meteorjs-2019/</link>
      <pubDate>Wed, 06 Mar 2019 06:30:00 +0000</pubDate>
      
      <guid>https://techformist.com/universal-apps-meteorjs-2019/</guid>
      <description>&lt;p&gt;I was a MeteorJS fan.&lt;/p&gt;
&lt;p&gt;MeteorJS was an excellent tool to quickly create universal apps. I was not quite a professional developer back in the day (circa 2016-17) but I could recognize the power of Meteor in developing complex web applications that could potentially deployed for multiple devices.&lt;/p&gt;
&lt;p&gt;There was a time when I was flabbergasted as I, rather alarmingly, saw people moving from Meteor to different platforms. I could not quite understand why.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>I was a MeteorJS fan.</p>
<p>MeteorJS was an excellent tool to quickly create universal apps. I was not quite a professional developer back in the day (circa 2016-17) but I could recognize the power of Meteor in developing complex web applications that could potentially deployed for multiple devices.</p>
<p>There was a time when I was flabbergasted as I, rather alarmingly, saw people moving from Meteor to different platforms. I could not quite understand why.</p>
<p>On one hand I was still a believer in Meteor world which could make magic happen and quickly. On the other hand, there were people like Arunoda <a href="https://medium.com/kadira-voice/say-no-to-isomorphic-apps-b7b7c419c634">telling people why they thought it was a bad idea</a>.(Just to get the context right, Arunoda and his team made excellent contributions to Meteor.)</p>
<p>So, why did I like Meteor in the first place -</p>
<ol>
<li>Simple to code</li>
<li>Simple to understand</li>
<li>Build reactive applications. Server controls sessions and can easily send events to clients</li>
<li>A lot of libraries</li>
<li>Share server and client code</li>
<li>Deploy easily</li>
</ol>
<p>I faced a few inherent issues-</p>
<ol>
<li>Meteor needed a bigger server. Well, I was comparing to PHP that could happily run a shared server. Even today, I don&rsquo;t quite imagine using Meteor to smoothly run a data-driven application that I have today on a 2 GB RAM server</li>
<li>Development with hot reload was kind of slower for my taste, but nothing significant</li>
<li>I don&rsquo;t quite like the idea of maintaining user sessions (the Meteor way?) - primarily because of the nature of applications I used to build</li>
<li>A lot of &ldquo;dead spots&rdquo;. Meteor decided to change big time when the users had emigrated to other technologies. With a smaller community the content created on help slowed down. The older content was sometimes applicable or not - which was a constant concern for a then hobbyist developer like me</li>
</ol>
<p>None of the issues were strong enough for me to stay away from Meteor but at the same time I did not quite embrace it as I have done so with other technologies. Yes, I did experiment with React on Meteor, and <a href="http://vulcanjs.org/">VulcanJS</a>,and I know people still recommend MeteorJS as one of the frameworks to evaluate.</p>
<p>So, why? Was/is Meteor a failure? Are such applications a relic of the past?</p>
<p>The answer - no, and no.</p>
<p>Meteor had its time in the golden age of Javascript. There are nuances to why I would rather not go there again -</p>
<ol>
<li>Meteor technology is not as actively developed as it used to be. Though it embraced the latest frontend technologies (think React / Vue), I do not quite see that picking up and going back to its heyday. People are weary of changes I think and they may rather jump on to a train that is already bustling with activity</li>
<li>The pub/sub model is the greatest of advantages, but may not be as relevant in today&rsquo;s world. I love the simplicity of server changes being reflected to &ldquo;interested&rdquo; clients, but I can do the same today using web sockets, GraphQL subscriptions and what not. Other technologies have a larger community (= more help) and growing</li>
<li>I have increasingly liked the clear client/server separation - primarily due to what I could do with server APIs including consuming them in mobile apps, PWAs, web apps and even desktop apps</li>
<li>I am excited about what is happening in the PWA and WASM world. While Javascript has a play in the former, it will eventually get isolated in the latter</li>
</ol>
<p>Sure real-time applications are easily built on Meteor, but I would see a Vue + AdonisJS / FeatherJS app as equally simple.</p>
<p>There are things that Meteor may not be excellent at, but I am a believer in the model of a full-stack application that can enabled by such technologies. Contrary to beliefs of many a smart people (like what was written by Arunoda), I am a strong proponent to make development tooling simpler. This is done by combining technologies and making magic happen. Given an opportunity of a well-architected full-stack application I don&rsquo;t believe people will be jumping with joy at the prospect of using multiple platforms to get their application to the market.</p>
<p>In this light - I see <a href="https://dotnet.microsoft.com/apps/aspnet/web-apps/blazor">Blazor</a> as really promising. Blazor (specifically client-side Blazor) may be the next big thing to accomplish this goal of backend + frontend platform. I can code in a more succinct language than Javascript to spit out the code that can be used by browsers. Equally importantly, I can use the same (or most of the) code for my native mobile apps or desktop apps.</p>
<p>Rust looks equally promising, but I lack the knowledge to comment better. Rust simply does not have comparable tooling as C#.</p>
<p>While there is a core team that stands by Meteor to this day I don&rsquo;t quite think Meteor&rsquo;s age will ever come back. I really appreciated what Meteor did for me in the past, but it is time to move on.</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Save 1.618 per day developing stuff</title>
      <link>https://techformist.com/save-1.618-per-day-developing-stuff</link>
      <pubDate>Mon, 31 Dec 2018 04:43:00 +0000</pubDate>
      
      <guid>https://techformist.com/save-1.618-per-day-developing-stuff</guid>
      <description>&lt;p&gt;Most of my coding a few years back consisted of the following actions -&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Type slowly&lt;/li&gt;
&lt;li&gt;Type (a lot of) mistakes&lt;/li&gt;
&lt;li&gt;Use spaces and tabs to format. Get confused about loops and add ad-hoc spaces and tabs&lt;/li&gt;
&lt;li&gt;Curse my typing skills and the soul who invented spaces and tabs&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;While formatting code was also becoming an interim &amp;rsquo;thought provoker&amp;rsquo;, it was simply too much typing.&lt;/p&gt;
&lt;p&gt;Enter &lt;strong&gt;&lt;a href=&#34;https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode&#34;&gt;prettier&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Although my typing is only half as bad, I now have far less stuff to worry about.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>Most of my coding a few years back consisted of the following actions -</p>
<ol>
<li>Type slowly</li>
<li>Type (a lot of) mistakes</li>
<li>Use spaces and tabs to format. Get confused about loops and add ad-hoc spaces and tabs</li>
<li>Curse my typing skills and the soul who invented spaces and tabs</li>
</ol>
<p>While formatting code was also becoming an interim &rsquo;thought provoker&rsquo;, it was simply too much typing.</p>
<p>Enter <strong><a href="https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode">prettier</a></strong>.</p>
<p>Although my typing is only half as bad, I now have far less stuff to worry about.</p>
<ol>
<li>Type in any way I want - yes, even type entire program in one line if I am feeling particularly stupid</li>
<li>Save file</li>
</ol>
<ul>
<li>Prettier formats code to add spaces and tabs</li>
<li>Prettier adds stuff that I am lazy to type - (e.g. missing semicolons</li>
<li>Changes stuff that I don&rsquo;t do myself - e.g. change single quotes to double quotes</li>
<li>If the formatting does not happen correctly, I look for coding errors (typically a missing/misplaced bracket)</li>
</ul>
<p>The savings from all the avoided actions (despite my poor typing) amounts to 1.618 hours a day. That is thousands of hours in my life that can be invested in coding &lsquo;hello worlds&rsquo; in new programming languages.</p>
<p>Once you start using Prettier ** you will never go back **. Do that first if you have not done that and come back here.</p>
<p>Following are the &lsquo;Prettier&rsquo; settings that I find useful in VS Code (Ctrl + Shift + P &gt; Type &lsquo;prettier&rsquo; to search for related settings).</p>
<ul>
<li>
<p>Editor: Format On Save =&gt; True
Prettier is not that useful if you don&rsquo;t see it in action - <em>at.every.save</em>.</p>
</li>
<li>
<p>Prettier: Eslint Integration =&gt; True
Get ESLint to do its thing. Fall back to prettier if there are no ESLint rules. This is mondo useful in languages that are packed with community ESLint rules. I cannot quite hold everyone accountable for the superior practices that I follow. It is far easier to deploy ESLint (or any supported linting) to the development/deployment workflow to make sure every coder follows the same standards. The above flag takes care of any conflicts by using ESLint first and falling back to Prettier if there are no rules.</p>
</li>
<li>
<p>Prettier: Jsx Bracket Same Line =&gt; True
JSX has a lot of &lsquo;&gt;&rsquo; and it is annoying if that is moved to the next line. Keep JSX clean.</p>
</li>
<li>
<p>Prettier: Semi =&gt; True
Use semicolons. Don&rsquo;t believe the evil people who say otherwise.</p>
</li>
<li>
<p>Prettier: Tslint Integration =&gt; True
Similar to the first item on ESLint described earlier, but for TypeScript. Get TSLint to format, and kick into action for stuff that don&rsquo;t have any TSLint rules.</p>
</li>
</ul>
<p>PS: Yep - the 1.618 is a random number that represents Golden ratio. Did you really think I can ever be so focused on improvements?</p>
]]></content:encoded>
    </item>
    
  </channel>
</rss>
