<?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: Prosper Opara</title>
    <description>The latest articles on Forem by Prosper Opara (@kodekage).</description>
    <link>https://forem.com/kodekage</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%2F35082%2F29c5fb7d-fc4b-423a-8016-a69be46e88a0.jpg</url>
      <title>Forem: Prosper Opara</title>
      <link>https://forem.com/kodekage</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/kodekage"/>
    <language>en</language>
    <item>
      <title>Junior Developer Check List</title>
      <dc:creator>Prosper Opara</dc:creator>
      <pubDate>Sun, 21 Jun 2020 20:09:02 +0000</pubDate>
      <link>https://forem.com/kodekage/junior-developer-check-list-3k3d</link>
      <guid>https://forem.com/kodekage/junior-developer-check-list-3k3d</guid>
      <description>&lt;p&gt;Dear recruiters,&lt;/p&gt;

&lt;p&gt;When hiring Junior talents what does your checklist look like?&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>hiring</category>
      <category>career</category>
      <category>recruiting</category>
    </item>
    <item>
      <title>Node.js Module System</title>
      <dc:creator>Prosper Opara</dc:creator>
      <pubDate>Wed, 22 Apr 2020 13:04:08 +0000</pubDate>
      <link>https://forem.com/kodekage/node-js-module-system-359b</link>
      <guid>https://forem.com/kodekage/node-js-module-system-359b</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--A4w-dlIV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cc1ijb983a8x222cp1cf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--A4w-dlIV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cc1ijb983a8x222cp1cf.png" alt="Alt Text" width="819" height="460"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Node.js is a JavaScript run-time built on top of the chrome v8 engine. Succinctly, Node.js as a platform provides an environment outside of the traditional web browser for executing JavaScript code (It's important to note here that Node.js was created for building network applications using JavaScript).&lt;/p&gt;

&lt;p&gt;A typical production ready Node.js application is &lt;em&gt;feature&lt;/em&gt; intensive (the endpoints of Restful API's are typical example where each endpoint is a feature and have a unique responsibility) and demands some amount of logic which in turn demands that you code lots of functions that are responsible for realizing the different features that make up your application. To keep our application maintainable it's a good practice to split the different logic into smaller pieces that have specific responsibilities and then import these pieces of logic into the main application for reuse. In Node.js we are given a &lt;em&gt;module system&lt;/em&gt; which enable application developers to abstract logic into modules, export the modules to be used else where in our application. Understanding how the module system works is integral for writing maintainable Node.js applications.&lt;/p&gt;

&lt;p&gt;A module is a piece of a program with abstracted functionality needed by the entire program. Typically, a program in most cases is composed of different modules.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;NB: For the rest of this article, i'd be using &lt;em&gt;Node&lt;/em&gt; in place of &lt;strong&gt;Node.js&lt;/strong&gt; mostly because it takes lesser keystroke and that is pretty what it's called in the ecosystem.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  The Module System Architecture
&lt;/h1&gt;

&lt;p&gt;In Node every file is considered a module and before each file (module) is executed, it's wrapped within a &lt;em&gt;Module Wrapper&lt;/em&gt; function which exposes the following variables/arguments &lt;em&gt;module, exports, require, __filename, __dirname&lt;/em&gt; and looks something like;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;__filename&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;__dirname&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// module code goes in here&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;em&gt;exports&lt;/em&gt; and &lt;em&gt;module&lt;/em&gt; object exposed by the wrapper function enable the module to expose functions/objects to be used by other modules. the require object allows for the module to import other module(s), the &lt;em&gt;__filename, __dirname&lt;/em&gt; are both convenience variables for accessing the file and directory path of the module respectively. It's equally important to note that the variables exposed by the wrapper function are not globally scoped. Instead, they are locally scoped to the module and every other variable declared within the module (in the global scope of the module) are also not directly accessible by other modules when the module is imported into another module except these variable are explicitly exported by the module. Hence, object naming collision is easily avoided between the importing module and imported module.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;NB: Please note that file and module can be used interchangeably, but i'd still explicitly remind you that to avoid any misunderstanding.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  module
&lt;/h2&gt;

&lt;p&gt;The &lt;em&gt;module&lt;/em&gt; variable is an object that represents the file in which it exits. Lets investigate this variable by creating an empty &lt;code&gt;index.js&lt;/code&gt; file(module) and logging the variable to console:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="cm"&gt;/*
  returns;

  Module {
  id: '.',
  path: 'C:\\Users\\kodekage\\Desktop\\projects\\node\\module',
  exports: {},
  parent: null,
  filename: 'C:\\Users\\kodekage\\Desktop\\projects\\node\\module\\index.js',
  loaded: false,
  children: [],
  paths: [
    'C:\\Users\\kodekage\\Desktop\\projects\\node\\module\\node_modules',
    'C:\\Users\\kodekage\\Desktop\\projects\\node\\node_modules',
    'C:\\Users\\kodekage\\Desktop\\projects\\node_modules',
    'C:\\Users\\kodekage\\Desktop\\node_modules',
    'C:\\Users\\kodekage\\node_modules',
    'C:\\Users\\node_modules',
    'C:\\node_modules'
  ]
}

*/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;NB: The output you see here will slightly differ from yours due to the simple fact that we are not using the same machine and you might have created your file in a totally different folder.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  module.exports
&lt;/h3&gt;

&lt;p&gt;module.exports property exposes values from the module which can be imported into other modules by &lt;code&gt;require('/path/to/module')&lt;/code&gt; and reused. Let's create a &lt;em&gt;utility.js&lt;/em&gt; module, that exposes an addition and subtraction function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;//utility.js&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;add&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&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;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&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;subtract&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&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;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;add&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;subtract&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;subtract&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;module.exports.add&lt;/em&gt; pushes the &lt;strong&gt;add function&lt;/strong&gt; into the exports object assigning &lt;em&gt;add&lt;/em&gt; as the key and the &lt;em&gt;add function&lt;/em&gt; as the value. &lt;strong&gt;module.exports.subtract&lt;/strong&gt; also assigns subtract as the second property of the exports object within the &lt;em&gt;module&lt;/em&gt; object. To further illustrate this, let's log the module object to the console.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// utility.js&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="cm"&gt;/*
  returns;

  Module {
  id: '.',
  path: 'C:\\Users\\kodekage\\Desktop\\projects\\node\\module',
  exports: { add: [Function: add], subtract: [Function: subtract] },
  parent: null,
  filename: 'C:\\Users\\kodekage\\Desktop\\projects\\node\\module\\index.js',
  loaded: false,
  children: [],
  paths: [
    'C:\\Users\\kodekage\\Desktop\\projects\\node\\module\\node_modules',
    'C:\\Users\\kodekage\\Desktop\\projects\\node\\node_modules',
    'C:\\Users\\kodekage\\Desktop\\projects\\node_modules',
    'C:\\Users\\kodekage\\Desktop\\node_modules',
    'C:\\Users\\kodekage\\node_modules',
    'C:\\Users\\node_modules',
    'C:\\node_modules'
  ]
}

*/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the exports property looks something like; &lt;code&gt;exports: { add: [Function: add], subtract: [Function: subtract] },&lt;/code&gt;. Indicating that the functions have being successfully exposed. When &lt;em&gt;utility.js&lt;/em&gt; is required in another module, the functions can be called within the requiring module.&lt;/p&gt;

&lt;h3&gt;
  
  
  exports
&lt;/h3&gt;

&lt;p&gt;exports is a convenience method for &lt;em&gt;module.exports&lt;/em&gt; as it takes lesser keystroke and is also succinct. Drawing from our previous code sample, &lt;em&gt;module.exports.add&lt;/em&gt; and &lt;em&gt;module.exports.subtract&lt;/em&gt; can also be written as &lt;em&gt;exports.add&lt;/em&gt; and &lt;em&gt;exports.subtract&lt;/em&gt; respectively.&lt;/p&gt;

&lt;h2&gt;
  
  
  require
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;require&lt;/em&gt; is a function used for loading a module into another module. It exposes the imported(the module been required) modules exported objects and makes them usable withing the requiring module.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// program.js&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;utility&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./utility&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;utility&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// returns 11&lt;/span&gt;
&lt;span class="nx"&gt;utility&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;substract&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// returns -3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are are different types of module you can typically load by calling the require function;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Node core module e.g http, fs, net, etc&lt;/li&gt;
&lt;li&gt;Application dependency module, typically loaded from node_modules&lt;/li&gt;
&lt;li&gt;local module/files&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When loading a core module or a module in the node_modules folder you simply reference the module name e.g; &lt;code&gt;const http = require('http')&lt;/code&gt;, &lt;code&gt;cosnt socketIo = require('scoket.io')&lt;/code&gt;. To load a local module(file) you need to add the file path to the module e.g &lt;code&gt;const utility = require('./utility)&lt;/code&gt; this means the utility module is in the same directory as the module importing it.&lt;/p&gt;

&lt;h3&gt;
  
  
  How Module loading works
&lt;/h3&gt;

&lt;p&gt;when loading a module node checks if the module identifier (the string passed into the require function call) begins with &lt;em&gt;'./'&lt;/em&gt; or &lt;em&gt;'/'&lt;/em&gt; or &lt;em&gt;'../'&lt;/em&gt; and when they don't Node checks if the identifier matches any of it's core module (http, net, fs, etc) and it finds a match, it loads the identified core module else Node knows to look into &lt;em&gt;node_modules&lt;/em&gt; folder for the required module.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;'./'&lt;/strong&gt; is a relative path to the module and it means that both modules (the imported module and the importing module) must be in the same directory&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;'../'&lt;/strong&gt; is also indicates a relative file path to the module, but this time both modules are not in the same directory level.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;'/'&lt;/strong&gt; is an absolute path to the module, and node starts looking from the root of the file system&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Note on&lt;code&gt;Node_modules&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;The node_modules directory is a repository for third party modules downloaded from package managers like npm or yarn. Node loads modules(packages) from this folder when the identifier passed into the &lt;em&gt;require&lt;/em&gt; function is not a core module or the identifier does not begin with './', '/' or '../'. In order to load from node_modules, Node keeps appending &lt;em&gt;"/node_modules"&lt;/em&gt; to the file path starting from the parent directory of the requiring module, then node keeps moving up the tree till it locates the file.&lt;/p&gt;

&lt;p&gt;Imagine you created a &lt;em&gt;program.js&lt;/em&gt; file in &lt;em&gt;$HOME/projects/sample-node-app/program.js&lt;/em&gt; which requires a &lt;em&gt;utility.js&lt;/em&gt; module which happens not to be a core module and the identifier does not begin with an absolute path "/" or relative path "./" or "../".&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// program.js&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;utility&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;utility&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Node next assumption will be that this module must be in a node_modules folder. Node will start it's search by firstly appending node_module to current directory of the requiring module(file) which for example might be &lt;em&gt;$HOME/projects/sample-node-app/&lt;/em&gt;&lt;em&gt;node_modules&lt;/em&gt;&lt;em&gt;/utility.js&lt;/em&gt; (where $HOME is a short cut environmental variable to the users home), if the file is not found there Node moves it's search to the parent directory; &lt;em&gt;$HOME/projects/node_modules/utility.js&lt;/em&gt;. If the module is also not found, Node keeps moving up the parent directory till it gets to the root directory of the file system and if the module is still not found, Node throws an error stating that it could not find the required module. An important point to note here is that Node &lt;strong&gt;will not&lt;/strong&gt; append a &lt;em&gt;/node_modules&lt;/em&gt; directory to any directory that already has a node_modules folder created in it or a path that ends with &lt;em&gt;/node_modules&lt;/em&gt;. Node will instead jump into the existing node_module directory to look for the required module.&lt;/p&gt;

&lt;p&gt;This is basically one of the reason a node_modules directory is created in the root of your project directory when you install third party modules &lt;em&gt;locally&lt;/em&gt; from npm or yarn.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Node's implementation of a module system is really unique especially the way Node  handles module scoping (thanks to the Module Wrapper function). Now package creators can name objects the way they choose without worrying about naming clashes, Package managers can utilize the power of node_modules for delivering the packages your Node application depends on and also as a Node developer you can worry less about this trivial matters and focus your energy on writing maintainable code.&lt;/p&gt;

&lt;p&gt;I strongly recommend you experiment with the idea your just absorbed and also dig into &lt;a href="https://nodejs.org/api/modules.html"&gt;the API documentation&lt;/a&gt; for a deeper dive into Node module system.&lt;/p&gt;

</description>
      <category>node</category>
      <category>javascript</category>
      <category>npm</category>
    </item>
    <item>
      <title>LEARNING: A developers perspective</title>
      <dc:creator>Prosper Opara</dc:creator>
      <pubDate>Fri, 13 Mar 2020 15:18:46 +0000</pubDate>
      <link>https://forem.com/kodekage/learning-a-developers-perspective-519n</link>
      <guid>https://forem.com/kodekage/learning-a-developers-perspective-519n</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--y3LpF-nn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/github-com-opara-prosper/image/upload/w_1000%2Car_16:9%2Cc_fill%2Cg_auto%2Ce_sharpen/v1584111509/dreyfus-img_dkeqgb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--y3LpF-nn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/github-com-opara-prosper/image/upload/w_1000%2Car_16:9%2Cc_fill%2Cg_auto%2Ce_sharpen/v1584111509/dreyfus-img_dkeqgb.png" alt="Article hero image" width="880" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Growing is the ultimate aim of every developer. Growing to understand how tools or systems work under the hood, going beyond the basics into deeper things or having a holistic understanding of the technologies you associate yourself which is truly the ultimate goal. The aim (to grow) is pretty much known by a lot of persons but the "HOW" of going about growing is what a lot of persons either don't fully understand, unknowingly ignores or totally are ignorant about. What is the best way to approach learning as a developer? How can we optimize learning to get the best possible results to help us grow, move to the next level of expertise and solve complex problems?&lt;/p&gt;

&lt;p&gt;Over the years, computer scientist and engineers have solved software related problems repeatedly and have come up with series of solutions for solving these problems. Some have gone further to organize their approach to solving this reoccurring problems and these solutions have come to be termed &lt;em&gt;design patterns&lt;/em&gt; - an approach to solving particular problems. In similar light, learning is a common "problem" that everyone must "solve" and luckily for us (everyone trying to gain expertise) the road from novice to expert is one that has being journeyed by many who are today experts in the field and even studied by some. Learning over the years has being deconstructed and we now have a road map that has proven to be reliable for learning new skills and growing to become an expert. This article is an attempt to share some of the insights discovered on how best to learn and I trust you're equally excited as I was writing this piece to discover how to go about learning as a developer&lt;/p&gt;

&lt;h3&gt;
  
  
  Dreyfus Model
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CpQXhcgu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/github-com-opara-prosper/image/upload/w_1000%2Car_16:9%2Cc_fill%2Cg_auto%2Ce_sharpen/v1584111501/dreyfus_skns9e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CpQXhcgu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/github-com-opara-prosper/image/upload/w_1000%2Car_16:9%2Cc_fill%2Cg_auto%2Ce_sharpen/v1584111501/dreyfus_skns9e.png" alt="Dreyfus model" width="880" height="495"&gt;&lt;/a&gt;&lt;br&gt;
We primarily learn to be more knowledgeable in specific skill sets or fields; language specific skills (JavaScript, ruby, react, rails, MySQL), fields (full-stack development, front-end development, developer advocacy, cloud engineering etc). It's a great thing to be able to measure learning in order to know how much we are really growing and advancing to the level of expertise.&lt;/p&gt;

&lt;p&gt;The Dreyfus model for skill acquisition is a model developed by the Dreyfus brothers (Staurt and Hubert Dreyfus) and it breaks down the journey from novice to expertise for any skill set into 5 levels;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Novice&lt;/li&gt;
&lt;li&gt;Advanced Beginners&lt;/li&gt;
&lt;li&gt;Competent&lt;/li&gt;
&lt;li&gt;Proficients&lt;/li&gt;
&lt;li&gt;Experts&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Novice
&lt;/h4&gt;

&lt;p&gt;The Novice is the first step for the model. A novice is a skill practitioner that is just starting out and has &lt;em&gt;very little&lt;/em&gt; or &lt;em&gt;No&lt;/em&gt; experience actively practicing a particular skill, the most import trait of a novice is that they are &lt;em&gt;experience deficient&lt;/em&gt; (obviously because they are just starting out). To be successful at practicing the skill at which they are novices, the novice requires specific rules to follow showing them what to do to get things done.&lt;/p&gt;

&lt;h4&gt;
  
  
  Advanced Beginners
&lt;/h4&gt;

&lt;p&gt;An advanced beginner is a skill practitioner that has &lt;em&gt;some&lt;/em&gt; experience practicing a particular skill. They have gone from &lt;em&gt;NO&lt;/em&gt; experience by building the foundation(requisite knowledge) required for the skill and also have some practice time working actively with the skill and when discussion regarding the skill arises they wont feel totally lost because they know a lot the basics. But this practitioners do not know how to troubleshoot errors or problems that arise from practicing the skill mostly because they've being dependent on rules (they just got off the novice phase, woof) and still depend a bit on those rules to get work done.&lt;/p&gt;

&lt;h4&gt;
  
  
  Competent
&lt;/h4&gt;

&lt;p&gt;Competent practitioners of a skill are able to troubleshoot unlike the advanced beginners because they have &lt;em&gt;more practice time&lt;/em&gt;, they have learnt how to solve specific problems and are able to recognize the patterns around these problems. When they encounter the same or similar problems they know what to do (they draw from their past experience to troubleshoot). They have &lt;em&gt;more&lt;/em&gt; experience than the preceding phase (Advanced Beginner) on the Dreyfus model.&lt;/p&gt;

&lt;h4&gt;
  
  
  Proficients
&lt;/h4&gt;

&lt;p&gt;Proficient practitioners can self correct, they are closer to the expert mark, they have outgrown the hard rules for getting work done and work with patterns or principles - also called maxims. Because they have &lt;em&gt;a lot of practice time&lt;/em&gt; they make problem solving decisions very quickly which in turn means they get things done pretty much quickly.&lt;/p&gt;

&lt;h4&gt;
  
  
  Experts
&lt;/h4&gt;

&lt;p&gt;This is the last stage of the Dreyfus model and I personally love to call experts practitioners "the boss". This folks are persons able to work from &lt;strong&gt;intuition&lt;/strong&gt; (the ability to understand something instinctively, without the need for conscious reasoning). They have &lt;strong&gt;sufficient&lt;/strong&gt; funds in their experience bank and they can withdraw unconsciously from this bank when making design decisions or problem solving. They are not limited by rules and really do not work well with rules. Their most important trait is working from intuition (which happens to be the test for expertise).&lt;/p&gt;

&lt;p&gt;The most prominent difference between the Dreyfus skill practitioners is &lt;strong&gt;Experience&lt;/strong&gt;. Experience  makes the difference in productivity, reasoning, approach to problem solving and delivery. Experience can not be bought or installed (like we install software), rather experience is something gained as a reward for active practice of a particular skill.&lt;/p&gt;

&lt;p&gt;We gain experience by many hours of deliberately committing to a particular skill and overcoming boisterous problems that arise from your limited knowledge of the skill.&lt;/p&gt;

&lt;h3&gt;
  
  
  Learn By Doing (Deliberate Practice)
&lt;/h3&gt;

&lt;p&gt;Practicing is a superior form of learning because it get's you to DO. It is only by doing that the required muscle memory is built, confidence to approach bugs established and the speed needed to deliver projects within the skill domain guaranteed. What are the best ways to approach learning by doing?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Be Purposeful&lt;/strong&gt; -&lt;br&gt;
Being purposely means, you have an end goal for doing something.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Be consistent&lt;/strong&gt; -&lt;br&gt;
Consistency is key to building expertise. Repeatedly visiting the gym at close intervals (daily, weekly) guarantees muscle building. Also consistently practicing at close intervals ensures that you solidify existing knowledge and build new knowledge base that advance your holistic understanding of any skill you're trying to build expertise around. Be intentionally consistent, and overtime you'd discover consistency becomes a part of you.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Be Focused&lt;/strong&gt; -&lt;br&gt;
The biggest threat to practicing and learning generally is &lt;strong&gt;distraction&lt;/strong&gt;. We already live in a world filled with a lot of things begging for our attention but we have limited attention and can only focus on a few things at a time. To succeed with your learning plans, you have to create a system that encourages unbroken concentration and that affords you the opportunity to learn deeply. Some ideas;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Set out time daily for which you dedicate to learning&lt;/li&gt;
&lt;li&gt;Create a spot, zone where you can lock yourself and be free from disturbance&lt;/li&gt;
&lt;li&gt;Block out notifications from social apps (Emails, twitter, Facebook etc)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Get feedback&lt;/strong&gt; - &lt;br&gt;&lt;br&gt;
Feedback are important for measuring progress and discovering error in judgement. Some ideas for getting feedback is to have someone review the output of the practice time (for instance your project code), or work on a project with someone more knowledgeable than you are. These way you get insights into your mistakes and learn very quickly things you don't know.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The idea is to plunge yourself into deliberately practicing the skill consistently and overtime your practice time will begin to transcend into expertise, you'd begin to think differently and approach problems differently as you advance through the different Dreyfus stages. Gaining experience will only remain a heart cry if we do not to go forth and intentionally learn what we need to gain the desired experience.&lt;/p&gt;

&lt;p&gt;Lastly, take some step back to access your current abilities with any particular skill you want to gain experience in. Using the Dreyfus model determine where you on the ladder, identify the required time commitment each day you'd be willing to commit, also identify the learning resource from where you can gather information on the skill and make the ultimate decision to be committed and consistent with the life changing activity of practicing.&lt;/p&gt;

&lt;p&gt;If you love this article, I'd love to get your feedback in the comment section and any feedback(thought) you have regarding the topic.&lt;/p&gt;

&lt;p&gt;P.S: Here is a &lt;a href="https://speakerdeck.com/opara_prosper79/learning-a-developers-perspective-c6f2f021-3939-46f1-86fe-1108734bd66c"&gt;link to slides&lt;/a&gt; I created on this topic.&lt;/p&gt;

</description>
      <category>learning</category>
      <category>growth</category>
      <category>softwaredevelopment</category>
      <category>skillacqusition</category>
    </item>
    <item>
      <title>Understanding Node Error [ERR_HTTP_HEADERS_SENT]</title>
      <dc:creator>Prosper Opara</dc:creator>
      <pubDate>Tue, 03 Dec 2019 04:22:17 +0000</pubDate>
      <link>https://forem.com/kodekage/understanding-node-error-errhttpheaderssent-19af</link>
      <guid>https://forem.com/kodekage/understanding-node-error-errhttpheaderssent-19af</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--j1mUA5_w--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ucarecdn.com/e0a5b7b8-33ad-4304-9c1c-0253f97bf48c/" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--j1mUA5_w--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ucarecdn.com/e0a5b7b8-33ad-4304-9c1c-0253f97bf48c/" alt="header-image" width="880" height="660"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Chances are as a NodeJS developer you've encountered this runtime error:&lt;br&gt;
&lt;strong&gt;[ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You must have written the perfect code and expect a flawless code excution (i wish 😆), but here is this runtime error shattering your expectations and definitely keeping you from moving on to other concerns of your project. Now you begin to ask yourself why you even choose this career path or even why you picked up node in the first place.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SPOILER ALERT&lt;/strong&gt;: I have run into this runtime error couple times while building restful API's and this is an effort to document what i learnt about this error, shorten your debugging time, help you understand why this error is thrown and finally how best handle it.&lt;/p&gt;
&lt;h2&gt;
  
  
  Uncovering the mystry
&lt;/h2&gt;

&lt;p&gt;Error [ERR_HTTP_HEADERS_SENT] is an interesting error that is fired up when a server tries to send more than one response to a client. What this means is that for a given client request the server previously sent a response (either a success responsei with the resource requested or error response for a bad request) back to the client and now is &lt;strong&gt;unexpectedly&lt;/strong&gt; trying to send another response :(&lt;/p&gt;
&lt;h2&gt;
  
  
  [Case Study] talk is cheap
&lt;/h2&gt;


&lt;div class="highlight js-code-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;express&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express&lt;/span&gt;&lt;span class="dl"&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;bodyParser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;body-parser&lt;/span&gt;&lt;span class="dl"&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;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bodyParser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&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;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;error&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;req body cannot be empty&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;succes&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&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="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Server live&lt;/span&gt;&lt;span class="dl"&gt;'&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;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RuRFetwQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ucarecdn.com/1aa8cb2b-2e61-469b-ad36-3b0953d5a348/" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RuRFetwQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ucarecdn.com/1aa8cb2b-2e61-469b-ad36-3b0953d5a348/" alt="post_request.png" width="880" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This case study is based on a simple POST request to a &lt;code&gt;/test&lt;/code&gt; route using the express framework. &lt;/p&gt;

&lt;p&gt;By design the server should send back a 400(Bad request) JSON response to the client if a request does not have a body(req.body) added to the request to ther server from the client (handled with the javascript if statement) and lastly if the request comes with a body a 200(OK) JSON respresention of the request body is sent back to the client as response . The expectation is that the request handler should do what we've programmed it to do (return response to the client). The request handler(the anononymous function that takes the &lt;strong&gt;req&lt;/strong&gt; &amp;amp; &lt;strong&gt;res&lt;/strong&gt; arguements) is simply a javascript function and this means that the javascript engine(v8 in nodes case) keeps executing the code beyond the &lt;strong&gt;if&lt;/strong&gt; statement when there is no explicit instruction for it to exit the function. &lt;/p&gt;

&lt;p&gt;Looking at the code logic you'd aggree that the request handler function has no explicit command for exiting the function in a situation a reqest body is not found and the error response is sent back to the client, therefore after the if statement condition has being resolved the server tries to send another response to the client :( and this is where the error kicks in.&lt;/p&gt;

&lt;p&gt;The request handler function already sent a response to the client using the res.json() method which automatically sets the response header(every response to the client should contain headers) for the response(in this case the&lt;code&gt;Content-Type&lt;/code&gt; to &lt;code&gt;application/json&lt;/code&gt;). Node picks up this atrocity and our server crashes because express under the hood is attempting to set the response header for this second response, hence the error message:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Cannot set headers after they are sent to the client&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EUVkPXyF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ucarecdn.com/79954b2e-1a7d-4f68-a720-205d3a030694/" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EUVkPXyF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ucarecdn.com/79954b2e-1a7d-4f68-a720-205d3a030694/" alt="headers-error.png" width="880" height="385"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Fixing the error
&lt;/h2&gt;

&lt;p&gt;The simple fix for this error is to add javascript &lt;code&gt;return&lt;/code&gt; statement to the response being sent from the if conditional to ensure that the request handler function exits(terminate) excuting code with the function once a response has being sent to the client.&lt;/p&gt;

&lt;p&gt;The description for the &lt;strong&gt;&lt;code&gt;return&lt;/code&gt;&lt;/strong&gt; statement on &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return"&gt;MDN&lt;/a&gt; states&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;When a return statement is used in a function body, the execution of the function is stopped. If specified, a given value is returned to the function caller.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;With this in mind, our request handler function should be modified to include a return statement like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;express&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express&lt;/span&gt;&lt;span class="dl"&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;bodyParser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;body-parser&lt;/span&gt;&lt;span class="dl"&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;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bodyParser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&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;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;error&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;req body cannot be empty&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;succes&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&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="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Server live&lt;/span&gt;&lt;span class="dl"&gt;'&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;p&gt;When a client makes a server request to this endpoint with or without a request body to the server request, the server sends the correct response and stop the function execution as necessary.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--n1K1EeUi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ucarecdn.com/6f506581-4f7d-4918-8c3e-5a352f65b53e/" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--n1K1EeUi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ucarecdn.com/6f506581-4f7d-4918-8c3e-5a352f65b53e/" alt="post_req.png" width="880" height="350"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You'd be tempted to ask why the last server response has no return statement sending it to the client?, well in this case there is really no need to return it since there is no code further down the function to be excuted so it means the the request handler stops excuting since it has comee to the end of the road. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The point is that Javascript return statement exits the request handler function (to prevent further code execution) and sends &lt;strong&gt;a&lt;/strong&gt; response object back to the client.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Hopefully, you now have a better understanding of why this error message is fired and how to resolve it 😄, and i hope by documenting this error and it's fix I shorten your debugging time and helped you understand why this error is fired.&lt;/p&gt;

&lt;p&gt;I have a &lt;a href="https://github.com/OPARA-PROSPER/node-server-error"&gt;GitHub repository&lt;/a&gt; for the failing code and passing code, you can clone and play with the code by trying out some other use case (hopefully can send a PR for your use case).&lt;/p&gt;

&lt;p&gt;Thanks for reading&lt;/p&gt;

</description>
      <category>node</category>
      <category>express</category>
      <category>web</category>
      <category>api</category>
    </item>
    <item>
      <title>Elixir is functional Ruby?</title>
      <dc:creator>Prosper Opara</dc:creator>
      <pubDate>Mon, 10 Jun 2019 13:34:26 +0000</pubDate>
      <link>https://forem.com/kodekage/elixir-is-functional-ruby-2p5k</link>
      <guid>https://forem.com/kodekage/elixir-is-functional-ruby-2p5k</guid>
      <description>&lt;p&gt;"Elixir is functional Ruby"&lt;/p&gt;

&lt;p&gt;I just started digging into elixir and ecosystem and can't get this description for elixir off my head. So I decided to start a discussion here, so I can get opinions of experienced Ruby developers writing elixir, and also elixir devs.&lt;/p&gt;

&lt;p&gt;My reasons&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;syntactic similarities&lt;/li&gt;
&lt;li&gt;Elixir like Ruby has a MVC web applications framework phenoix&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What do we think about this?&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>elixir</category>
      <category>ruby</category>
      <category>functional</category>
    </item>
    <item>
      <title>Reinventing ruby flatten method</title>
      <dc:creator>Prosper Opara</dc:creator>
      <pubDate>Fri, 17 May 2019 10:30:43 +0000</pubDate>
      <link>https://forem.com/prosper/reinventing-ruby-flatten-method-4lpc</link>
      <guid>https://forem.com/prosper/reinventing-ruby-flatten-method-4lpc</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZPmFAg_C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/OPARA-PROSPER/Technical-Articles/master/git-backend/img/flatten.jpeg%3Ftoken%3DAHGMCDH5R2WYFKEEAQ7Y6RC447BZC" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZPmFAg_C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/OPARA-PROSPER/Technical-Articles/master/git-backend/img/flatten.jpeg%3Ftoken%3DAHGMCDH5R2WYFKEEAQ7Y6RC447BZC" alt="Flattening a human"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;I actively started re-learning ruby by solving challenge exercise from &lt;a href="https://exercism.io"&gt;exercism&lt;/a&gt; and I thought I should write about the challenges I found a bit difficult and overcame. You can check out &lt;a href="https://exercism.io/profiles/OPARA-PROSPER"&gt;my profile&lt;/a&gt; on exercsim to see my progress.&lt;/p&gt;

&lt;h3&gt;
  
  
  Problem statement
&lt;/h3&gt;

&lt;p&gt;The Ruby Array flatten method takes any deeply nested array (Multi-dimensional) and returns a non nested array using &lt;a href="https://www.geeksforgeeks.org/recursion/"&gt;recursion&lt;/a&gt;. For example (open IRB[Interactive Ruby] in your terminal and run):&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,[[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;flatten&lt;/span&gt;
&lt;span class="c1"&gt;# =&amp;gt; [1, 3, 4, 6, 3, 7, 5, 1, 1, 2, 3, 5]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This challenge exercise requires that I write my personal implementation of the method, without using the method.&lt;/p&gt;

&lt;h3&gt;
  
  
  My Implementation
&lt;/h3&gt;

&lt;p&gt;My algorithm for solving this problem looked like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a &lt;code&gt;FlattenArray&lt;/code&gt; class with a &lt;code&gt;flatten&lt;/code&gt; class method&lt;/li&gt;
&lt;li&gt;The class method accepts a single array parameter &lt;code&gt;arr&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Create an emepty array &lt;code&gt;flattened&lt;/code&gt; to hold the elements of the new array.&lt;/li&gt;
&lt;li&gt;Loop through the array argument &lt;code&gt;arr&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Push each elements into &lt;code&gt;flattened&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Recursively push deeply nested array into &lt;code&gt;flattened&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Return the one-dimensional &lt;code&gt;flattened&lt;/code&gt; array&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Classes in Ruby are created by using the &lt;code&gt;class&lt;/code&gt; keyword, a &lt;code&gt;meaningful class name&lt;/code&gt; and the &lt;code&gt;end&lt;/code&gt; keyword.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;FlattenArray&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;From my algorithm, the class has a class method &lt;code&gt;flattened&lt;/code&gt;and accepts a single parameter/argument. In Ruby, the &lt;code&gt;self&lt;/code&gt; keyword is used for creating class methods (class methods are methods that belong to the class it was created in and not instances (objects) of the class).&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;FlattenArray&lt;/span&gt;
  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nc"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;flatten&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The next steps include;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creating the &lt;code&gt;flattened&lt;/code&gt; array&lt;/li&gt;
&lt;li&gt;Loop through the &lt;code&gt;arr&lt;/code&gt; parameter&lt;/li&gt;
&lt;li&gt;Push &lt;code&gt;arr&lt;/code&gt; elements into &lt;code&gt;flattened&lt;/code&gt; array&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For looping through the array parameter, we'd utilize the &lt;code&gt;each&lt;/code&gt; iterator (this loops through all the elements within an array, and allows you do manipulate the elements within a code block, and it additionally returns the original &lt;a href="https://ruby-doc.org/core-2.2.0/Enumerator.html"&gt;Enumerator&lt;/a&gt; without mutating it). Pushing the elements of &lt;code&gt;arr&lt;/code&gt; into the &lt;code&gt;flattened&lt;/code&gt; array possible with the use of  &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; or &lt;code&gt;.push&lt;/code&gt; method, but I'd be sticking with &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; (personal preference).&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;FlattenArray&lt;/span&gt;
  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nc"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;flatten&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;flattened&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;each&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;element&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
      &lt;span class="n"&gt;flattened&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;element&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The next step involves adding a call to the &lt;code&gt;flatten&lt;/code&gt; method within itself(this is called recursion) tp keep us from unnecessary nested iterations in cases of multi-dimensional array arguments.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;FlattenArray&lt;/span&gt;
  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nc"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;flatten&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;flattened&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;each&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;element&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;is_a?&lt;/span&gt; &lt;span class="no"&gt;Array&lt;/span&gt;
        &lt;span class="n"&gt;flattened&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;concat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flatten&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;element&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
      &lt;span class="k"&gt;else&lt;/span&gt;
        &lt;span class="n"&gt;flattened&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;element&lt;/span&gt;
      &lt;span class="k"&gt;end&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
    &lt;span class="n"&gt;flattened&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;My initial challenge was using &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; to push into the flattened array, which actually push an array object into  &lt;code&gt;flattened&lt;/code&gt;. Using &lt;code&gt;.concat&lt;/code&gt; method on the other hand &lt;strong&gt;appends&lt;/strong&gt; each element from the iteration into &lt;code&gt;flattened&lt;/code&gt; instead of pushing an array object. Testing manually to check if this implemetatio works &lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="nb"&gt;print&lt;/span&gt; &lt;span class="no"&gt;FlattenArray&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;flatten&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,[[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Omitting the parenthesis in a method call is allowable in ruby and correct ruby syntax. Also, I personally enjoy calling functions without parenthesis :)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Testing
&lt;/h3&gt;

&lt;p&gt;Another feature I love about learning on &lt;a href="https://exercism.io"&gt;exercism&lt;/a&gt; is that you'd solve the exercises using Test Driven Development(TDD) methodology and it's really cool I must say. Writing Test Suites in ruby requires that you have &lt;code&gt;minitest&lt;/code&gt; gem installed, you can install minitest using the &lt;code&gt;gem install&lt;/code&gt; command:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ gem install minitest
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Create a &lt;code&gt;flatten_test.rb&lt;/code&gt; file in the same directory with flatten.rb (File for our flatten implementation code), in the newly created file require the &lt;em&gt;minitest&lt;/em&gt; gem, require &lt;em&gt;flatten.rb&lt;/em&gt; (using &lt;code&gt;require_relative&lt;/code&gt;) and copy the following Test Suite:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="nb"&gt;require&lt;/span&gt; &lt;span class="s1"&gt;'minitest/autorun'&lt;/span&gt;
&lt;span class="nb"&gt;require&lt;/span&gt; &lt;span class="s1"&gt;'minitest/pride'&lt;/span&gt;
&lt;span class="nb"&gt;require_relative&lt;/span&gt; &lt;span class="s1"&gt;'flatten_array'&lt;/span&gt;

&lt;span class="c1"&gt;# Common test data version: 1.2.0 0290376&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;FlattenArrayTest&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;Minitest&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Test&lt;/span&gt;
  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;test_no_nesting&lt;/span&gt;
    &lt;span class="c1"&gt;# skip&lt;/span&gt;
    &lt;span class="n"&gt;flat_array&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;FlattenArray&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;flatten&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="n"&gt;assert_equal&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;flat_array&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;

  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;test_flattens_array_with_just_integers_present&lt;/span&gt;
    &lt;span class="c1"&gt;# skip&lt;/span&gt;
    &lt;span class="n"&gt;flat_array&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;FlattenArray&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;flatten&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="n"&gt;assert_equal&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;flat_array&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;

  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;test_5_level_nesting&lt;/span&gt;
    &lt;span class="c1"&gt;# skip&lt;/span&gt;
    &lt;span class="n"&gt;flat_array&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;FlattenArray&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;flatten&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[[[&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;]]]],&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="n"&gt;assert_equal&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;flat_array&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;

  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;test_6_level_nesting&lt;/span&gt;
    &lt;span class="c1"&gt;# skip&lt;/span&gt;
    &lt;span class="n"&gt;flat_array&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;FlattenArray&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;flatten&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]]],&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="n"&gt;assert_equal&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;flat_array&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Make sure to un-comment the &lt;code&gt;skip&lt;/code&gt; keyword within each test to enable the test code run and avoid &lt;strong&gt;skipping&lt;/strong&gt; that test case. You can now run the command below in terminal:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ruby flatten_test.rb
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;To learn more about writing test in ruby, read &lt;a href="http://tutorials.jumpstartlab.com/topics/testing/intro-to-tdd.html#intro-to-tdd"&gt;intro to TDD&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Wrap up
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://exercism.io"&gt;Exercism&lt;/a&gt; is an amazing tool for learning any programming language of your choice and also get mentorship while working on your solution. Exercism mentors don't hand you the fish, rather they give you the fish hook and tell you the coordinates of the fish, this totally makes fishing fun, research oriented and fast.&lt;/p&gt;

&lt;p&gt;If you followed the code implementation from beginning to end, you must have discovered how awesome the Ruby programming language is and how lienient the syntax is, &lt;a href="https://ruby-doc.org/"&gt;Ruby&lt;/a&gt; is one language i really enjoy writing and has an amazing &lt;a href="http://ruby-forum.com/"&gt;ecosystem&lt;/a&gt;   &lt;/p&gt;

</description>
    </item>
    <item>
      <title>The Mobile Developer</title>
      <dc:creator>Prosper Opara</dc:creator>
      <pubDate>Thu, 31 Jan 2019 12:10:09 +0000</pubDate>
      <link>https://forem.com/kodekage/the-mobile-developer-1ece</link>
      <guid>https://forem.com/kodekage/the-mobile-developer-1ece</guid>
      <description>&lt;p&gt;I started learning to code with my mobile device (Android) 2017 and it was really a defining moment for my journey as a web developer (I'm gradually transitioning to software development).&lt;/p&gt;

&lt;p&gt;I was passionate enough to begin learning to code with my mobile device against all odds and discomfort that accompanys learning to code with a mobile device. &lt;/p&gt;

&lt;p&gt;Over the years I have noticed most of the beginners reaching out to me with questions on how to learn to code, like me when I started, do not own a laptop or desktop computer to learn with. So I'd always motivate them to get started with their mobile device. &lt;/p&gt;

&lt;p&gt;But i decided to take it a little farther by writing a book teaching beginners how to start coding by Learning web development. I'm almost done writing the book and created a waiting list for readers that will love to read the book when it's finally out.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to expect
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Basic and in-depth explanations of web technologies like HTML, CSS and JavaScript&lt;/li&gt;
&lt;li&gt;Sample codes to build your muscles memory with&lt;/li&gt;
&lt;li&gt;Recipes for learning to code&lt;/li&gt;
&lt;li&gt;Motivation to continue your journey to becoming the beat Developer you can become.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is the &lt;a href="https://goo.gl/forms/3UHI4Rful3H8GjGg2"&gt;link to the waiting list&lt;/a&gt;&lt;/p&gt;

</description>
      <category>learntocode</category>
      <category>codenewbie</category>
      <category>mobiledevelopers</category>
    </item>
    <item>
      <title>GIT BACKEND (BEHIND THE SCENE)</title>
      <dc:creator>Prosper Opara</dc:creator>
      <pubDate>Wed, 07 Nov 2018 11:39:40 +0000</pubDate>
      <link>https://forem.com/kodekage/git-backend-behind-the-scene-12l5</link>
      <guid>https://forem.com/kodekage/git-backend-behind-the-scene-12l5</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3iNiTlvX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/nuaudq3junzpq0qanj88.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3iNiTlvX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/nuaudq3junzpq0qanj88.png" alt="Title image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;I have been digging into Git internals to really understand the tool &lt;strong&gt;beyond the basics&lt;/strong&gt; and gain an indepth understanding of how git does what it's known for -- &lt;strong&gt;Version Control&lt;/strong&gt;. In this article I intend to share with you my discoveries by exposing git internals in simple language as much as possible for any Git user to comprehend the core concepts behind this amazing tool.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important&lt;/strong&gt;: This article is not an introduction to Git material but it's intended to show you how Git is able to keep track of the various versions of your project files. If you're new to Git, follow this &lt;a href="https://git-scm.com/doc"&gt;Git documentation&lt;/a&gt; to get to read the documentation or download &lt;a href="https://git-scm.com/book/en/v2"&gt;progit&lt;/a&gt; to get an awesome explanation of Git basic's, then you can comeback to read this article for a deeper dive into Git. &lt;/p&gt;

&lt;h3&gt;
  
  
  GIT FRONT-END (What you already know)
&lt;/h3&gt;

&lt;p&gt;You surely know by now that Git at it's core is a version control system (VCS) used by people(&lt;em&gt;Now i did not say developers, anyone can use git for instance I used git to keep track of the various versions of this article as i wrote and made changes before publishing&lt;/em&gt;) to keep track of the different versions/iteratons of their project files(documents). &lt;/p&gt;

&lt;p&gt;Before Git numerous VCS existed e.g CVS, subversion, perforce and they are all categorized under the &lt;strong&gt;Central version control system (CVCS)&lt;/strong&gt; which means that all the versioned files are stored in one database and every other person(client) working with/on that project will have to connect to the central database (All commits goes into this singular database). &lt;/p&gt;

&lt;p&gt;Git on the other hand falls under the category of &lt;strong&gt;Distributed Version Control System (DVCS)&lt;/strong&gt;, which means that there are no central database where people have to push or save files to. Every Git user computer serves as a database for the files, it means that everyone working on the project has the whole history of the project living in their local machine as at the time they cloned the project. So where does this database sit in your computer? i'm pretty sure if you check your project directory were you use Git you will see only your project's sub-directories and files. I'd be exposing this Git magic inabit&lt;/p&gt;

&lt;h3&gt;
  
  
  GIT INTERNALS
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9fOU592e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/qgug2w2ycdl9fq7obxcf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9fOU592e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/qgug2w2ycdl9fq7obxcf.png" alt="Git Objects"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What makes a project directory a git repository is the &lt;strong&gt;hidden &lt;code&gt;.git directory&lt;/code&gt;&lt;/strong&gt; living in that project directory. The &lt;strong&gt;.git&lt;/strong&gt; folder houses the Git &lt;strong&gt;Object database&lt;/strong&gt; and this is where the Git magic happens. This folder is intentionally hidden to avoid stories that touches the heart (file mutaion, mistakes) and to maintain Git integrity. If you're a windows geek, you can view this folder by enabling &lt;code&gt;show hidden files&lt;/code&gt; feature, &lt;a href="https://www.laptopmag.com/articles/show-hidden-files-windows"&gt;follow this tutorial if you have no clue how to do this&lt;/a&gt;, if you're a mac user, &lt;a href="https://ianlunn.co.uk/articles/quickly-showhide-hidden-files-mac-os-x-mavericks/"&gt;here is your link&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;.git directory&lt;/strong&gt; houses some other directories and files and it looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- .git/
  - hooks
  - info/
    - exclude
  - objects/
    - info
    - pack
  - refs/
    - heads
    - tags
  - config
  - description
  - HEAD

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Git is able to effectively manage different versions of your project because it is designed to track file contents and store's the tracked contents as &lt;strong&gt;Objects&lt;/strong&gt; in an &lt;strong&gt;Object database&lt;/strong&gt;. &lt;/p&gt;

&lt;h3&gt;
  
  
  OBJECTS DIRECTORY
&lt;/h3&gt;

&lt;p&gt;Git works as a content addressable filesystem which means that Git stores it's files(objects) using a &lt;code&gt;key:value&lt;/code&gt; pair format, where the key is the address where Git stores the content(refered to as objects) which is the value.&lt;/p&gt;

&lt;p&gt;Git uses &lt;strong&gt;SHA-1(Secure Hash Algorithm)&lt;/strong&gt; to generate a unique key for every object is stores. The SHA-1 generates 40 character long alpha-numeric character to reference the objects stored in the object database eg &lt;code&gt;f7de3a39b026386f8f826bc230a112ae792ec035&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This &lt;strong&gt;object directory&lt;/strong&gt; is the location were Git stores every object i.e the &lt;strong&gt;object directory is the object database&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Mg5Jgj4W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/lxhve46c3heu4g9ifv5e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Mg5Jgj4W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/lxhve46c3heu4g9ifv5e.png" alt="Git Objects"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are three major object types stored by Git in the object database(Object directory), they are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Blobs Object&lt;/strong&gt; - Git stores file contents as blobs. It is important to note that blobs do not include the file name or the file mode, rather they are strictly contents from the files Git is versioning. The SHA-1 serves as the filename(key) for the blob contents(value).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Tree Object&lt;/strong&gt; - Tree objects are like directories, they contain blob objects and other tree objects. Tree objects are snapshots of your working directory at the time of your last commit.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Commit Object&lt;/strong&gt; - Commit objects basically stores details of the last commit of the currently checked out branch (this is referenced as &lt;strong&gt;parent&lt;/strong&gt;), a pointer to the current tree object for the commit, the name of the committer, and the actual commit message.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Git object types are organized in sub-directories git automatically creates when trying to store the objects. The sub-directory are named using the first two characters of the SHA-1, and the object are stored in a file named using the remaining 38 hash keys.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  Objects/
    f7/
      de3a39b026386f8f826bc230a112ae792ec035
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  GIT IN ACTION
&lt;/h2&gt;

&lt;p&gt;In this section we will be doing some versioning and seeing for ourself how Git objects are created and stored in the object database, i belive everything will begin to make more sense by the end of this section.&lt;/p&gt;

&lt;p&gt;I will be working with &lt;strong&gt;git bash&lt;/strong&gt; for the demostrations.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Open up your terminal/cmd and Cd into any directory of your choice, and type the command &lt;code&gt;$ git init&lt;/code&gt; to create an empty Git Repository. In my case i got the message &lt;code&gt;Initialized empty Git repository in C:/Users/opara prosper/Desktop/GitHub Projects/Git-Backend/.git/&lt;/code&gt; you would surely get a message similar but with a different directory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open up a new terminal and cd into the project directory and place both terminals side by side, this will enable us keep track of what is happening inside the .git directory.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Wd6pmkPe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/th4anb0k8uz80k850w5k.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Wd6pmkPe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/th4anb0k8uz80k850w5k.PNG" alt="Open Terminal"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Create a new file &lt;code&gt;example.txt&lt;/code&gt; to contain &lt;code&gt;Hello world&lt;/code&gt; as it's content - you can do this from your terminal by typing the following command &lt;code&gt;cat &amp;gt; example.txt&lt;/code&gt; then type the content on the new line, save and exit with &lt;strong&gt;CTRL D&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On the second terminal you opened type this command &lt;code&gt;find .git/objects -type f&lt;/code&gt; you will not get any response because there is nothing in the objects directory but that will soon change.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now on the first terminal we initially opened, type in the command &lt;code&gt;git add example.txt&lt;/code&gt; to move the file to the staging area.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Navigate back to the second terminal you opened and type &lt;code&gt;find .git/objects -type f&lt;/code&gt;. Now you'd get a response that looks like this &lt;code&gt;.git/objects/70/c379b63ffa0795fdbfbc128e5a2818397b7ef8&lt;/code&gt; your's will be different because SHA-1 creates random keys for git objects. This means an object has been added to Git's object database but we don't know what that is yet. If you type &lt;code&gt;git cat-file -p 70c379b63ffa0795fdbfbc128e5a2818397b7ef8&lt;/code&gt; you'd notice &lt;em&gt;hello world&lt;/em&gt; is returned, but the file name example.txt is no where to be found, this reinforces my claim of Git being a content tracker. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When you ran the &lt;code&gt;git add example.txt&lt;/code&gt; command, Git grabbed the contents within eample.txt and compressed it into the git object database and gave it a unique identifier &lt;strong&gt;70c379b63ffa0795fdbfbc128e5a2818397b7ef8&lt;/strong&gt; using SHA-1. To check the type of object this is type the following command &lt;code&gt;git cat-file -t 70c379b63ffa0795fdbfbc128e5a2818397b7ef8&lt;/code&gt;, in our case a &lt;em&gt;blob&lt;/em&gt; is returned meaning that the newly created object is a blob object.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Going back to our first terminal, type the following command &lt;code&gt;git commit -m "I created an example.txt file"&lt;/code&gt; to commit your changes(i.e to move your changes from the staging area into the .git directory).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Naviagate back to the second terminal and type &lt;code&gt;find .git/objects -type f&lt;/code&gt;, this time you'd notice that two new objects have been added to the objects directory, in my case;&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.git/objects/70/c379b63ffa0795fdbfbc128e5a2818397b7ef8
.git/objects/7a/68edc879868601bf427c8c2238bbc8752c33b3
.git/objects/f2/9f2741b30ecc1529da7dbae4aff9974b69e271
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Lets inspect these objects, grab the any of the object and type &lt;code&gt;git cat-file -t 7a68edc879868601bf427c8c2238bbc8752c33b3&lt;/code&gt;. In my case &lt;code&gt;commit&lt;/code&gt; was returned and this means that this object is a &lt;strong&gt;commit object&lt;/strong&gt;, to view this object chnage the &lt;code&gt;-t&lt;/code&gt; flag from our previous command to &lt;code&gt;-p&lt;/code&gt; i.e &lt;code&gt;git cat-file -p 7a68edc879868601bf427c8c2238bbc8752c33b3&lt;/code&gt; you'd get a response that looks like this;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tree f29f2741b30ecc1529da7dbae4aff9974b69e271
author OPARA-PROSPER &amp;lt;oparaprosper79@gmail.com&amp;gt; 1541583214 +0100
committer OPARA-PROSPER &amp;lt;oparaprosper79@gmail.com&amp;gt; 1541583214 +0100

I created an example.txt file

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Let's look closely at what this means. The first line &lt;em&gt;tree f29f2741b30ecc1529da7dbae4aff9974b69e271&lt;/em&gt; is a pointer to the second object that was created when we committed last (this object is always a tree object), the second and third line contains information about who made the commit and the last line contains the commit message.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now we will inspect the second object which was created alongside the commit using &lt;code&gt;git cat-file -t f29f2741b30ecc1529da7dbae4aff9974b69e271&lt;/code&gt;. A &lt;code&gt;tree&lt;/code&gt; response is returned which means that the object is a tree, we can view the contents of this tree object by changing the &lt;code&gt;-t&lt;/code&gt; flag to &lt;code&gt;-p&lt;/code&gt; i.e &lt;code&gt;git cat-file -p f29f2741b30ecc1529da7dbae4aff9974b69e271&lt;/code&gt;, this will return a response that looks like this;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;100644 blob 70c379b63ffa0795fdbfbc128e5a2818397b7ef8    example.txt

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Recall from my explanation that tree objects are like directories that contain blobs and other trees and also they are snapshots of the current state of your working directory at the time of your last commit. The only file in our working directory at the time we last commited is the &lt;em&gt;example.txt&lt;/em&gt; file and thats what our tree object contains but this time its the blob object that was created when we ran the git add command to stage our changes. This is so because Git does not track files but contents. &lt;/p&gt;

&lt;p&gt;Our tree object contain information on the file mode (100644 which means this is a normal file), the object type, the SHA-1 key and the file name from which the contents where extracted from. &lt;/p&gt;

&lt;h2&gt;
  
  
  WRAP UP
&lt;/h2&gt;

&lt;p&gt;The more changes you make, stage and commit the more new blobs, tree and commit objects will be created and referenced in the objects database.&lt;/p&gt;

&lt;p&gt;In conclusion, this is virtually how Git works under the hood to keep track of the changes we make to our project files.&lt;/p&gt;

</description>
      <category>git</category>
      <category>gitinternals</category>
      <category>versioncontrol</category>
    </item>
    <item>
      <title>World Wide Web</title>
      <dc:creator>Prosper Opara</dc:creator>
      <pubDate>Mon, 22 Oct 2018 08:56:11 +0000</pubDate>
      <link>https://forem.com/kodekage/world-wide-web-35l3</link>
      <guid>https://forem.com/kodekage/world-wide-web-35l3</guid>
      <description>&lt;p&gt;I’m opara prosper, and i have been building stuffs for the web for some time now…&lt;/p&gt;

&lt;p&gt;What i really love about the web is its &lt;em&gt;ACCESSIBILITY&lt;/em&gt; and &lt;em&gt;UNIVERSALITY&lt;/em&gt;. The web is for all people’s of the world. The web knows no bounds, doesn't restrict anyone from getting information they desire and It really help’s in promoting my personal mantra “Human knowledge is for everyone”. It is not limited by OS, hardware type or any of the accessibility issues other platforms face. Once you have a web browser you can visit the web and access life changing information's. The mare fact of building something that the world can see is really intriguing, I guess that’s why it’s rightly called the &lt;em&gt;world wide web(WWW)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Knowing that the web is accessible to all people, I look forward to improving my skill of building web applications with great user experience so that people can also enjoy their visit to the web. I’m particularly interested in building Interactive web applications, because it accounts a great deal for good user experience on the web.&lt;/p&gt;

&lt;p&gt;Moving forward, I’d love to write more and also speak more about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Web technologies&lt;/li&gt;
&lt;li&gt;Web accessibility&lt;/li&gt;
&lt;li&gt;User experience focused more around building interactive web applications.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I’d need to go back to work now to be able to achieve this :)&lt;/p&gt;

</description>
      <category>webaccessibility</category>
      <category>web</category>
    </item>
    <item>
      <title>CSS VARIABLE SCOPE</title>
      <dc:creator>Prosper Opara</dc:creator>
      <pubDate>Mon, 03 Sep 2018 16:56:00 +0000</pubDate>
      <link>https://forem.com/kodekage/css-variable-scpoe-13ki</link>
      <guid>https://forem.com/kodekage/css-variable-scpoe-13ki</guid>
      <description>&lt;p&gt;I think removing the native cascading effect of css variables will be awesome.&lt;/p&gt;

&lt;p&gt;variables should be accessible to other selectors not within the scope of the :root element.&lt;/p&gt;

&lt;p&gt;more like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
--variable_name: value;
}

selector{
    property: var(--variable_name);
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;code sample:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;index.html&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="question"&amp;gt;
    &amp;lt;h1&amp;gt;questions&amp;lt;/H1&amp;gt;

    &amp;lt;ul&amp;gt;
        &amp;lt;li&amp;gt;Whats your name&amp;lt;/li&amp;gt;
    &amp;lt;/ul&amp;gt;
&amp;lt;div&amp;gt;

&amp;lt;div class="greet"&amp;gt;
    &amp;lt;p&amp;gt;hello world&amp;lt;/p&amp;gt;
&amp;lt;/div&amp;gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;code&gt;index.css&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/*
proposed css variable declaration 
*/
{
 --bg_color: #111;
--font_color: #fff;
}

.question{
    background-color: var(--bg_color);
    color: var(--font_color);
}

/*
   The greet class is on a different scope from the question class, but still shares the varible values with .question
*/
.greet{
    background-color: var(--bg_color);
    color: var(--font_color);
}

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This are my thoughts though, I'd love to hear your thoughts about this too..&lt;/p&gt;

</description>
      <category>css</category>
      <category>styling</category>
      <category>frontenddevelopment</category>
    </item>
    <item>
      <title>BEGINNERS GUIDE TO JAVASCRIPT MODULES &amp; WEBPACK</title>
      <dc:creator>Prosper Opara</dc:creator>
      <pubDate>Thu, 19 Apr 2018 13:44:49 +0000</pubDate>
      <link>https://forem.com/kodekage/beginners-guide-to-javascript-modules--webpack-2gfm</link>
      <guid>https://forem.com/kodekage/beginners-guide-to-javascript-modules--webpack-2gfm</guid>
      <description>&lt;p&gt;Imagine you just arrived Lagos in Nigeria, and you want to get to your hotel from the the airport so you can relax after the long trip. Now Lagos is a large city made up of many other areas. To get to your hotel you need to first locate the town where the hotel is, also you need to know the street and building number of the hotel. If Lagos was not structured in different pieces comprising of town’s, street, building numbering it will be quite hard to transit the city. This Structure is MODULAR in nature( i.e having different pieces that can be connected to build up something ).&lt;/p&gt;

&lt;p&gt;JavaScript modules is a programming style that is based on the modular programming concept. Modular programming is a concept if understood can make life really easy for developers. Webpack is a tool that helps you manage your JavaScript modules and bundles these modules into one JavaScript file. Having a basic understanding of modules is a prerequisite for understanding what webpack is and what it can do for you as a developer, and that is what i intend to do with this article(give you a basic introduction to JavaScript modules). So let’s get started!&lt;/p&gt;

&lt;p&gt;Modular programming is a concept that advocates that you break up your codes into several pieces(known as MODULES) that can can used in other part of your code. So instead of having one large JavaScript file containing all the code for your project, you have pieces(modules) of codes that have different roles they play in your project and can be IMPORTED into other modules that needs them to function. So the the idea is that you import modules into other modules that are dependent on them, and also your make modules exportable so that they can be imported into any modules that require them. The keyword here are IMPORT and EXPORT.&lt;/p&gt;

&lt;p&gt;Now what is JavaScript modules?&lt;/p&gt;

&lt;p&gt;JavaScript modules are just different pieces of JavaScript codes that perform different functions and can be imported when required into other modules.&lt;/p&gt;

&lt;p&gt;Usually, the relevance of JavaScript modules is less significant when you have a little codebase but when codebase begins to grow into thousands and it starts becoming hard to keep track of the various functionalities of your code then you will see the need to write modular codes.&lt;/p&gt;

&lt;h1&gt;
  
  
  WHY SHOULD I WRITE MODULAR CODES?
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Modular Programming makes debugging less stressful.&lt;/li&gt;
&lt;li&gt;Modular programming helps your create reusable pieces of code that can be used in future projects without having to write those code again or copy them from your previous project.&lt;/li&gt;
&lt;li&gt;Modular programming makes code refactoring really easy! (just imagine refactoring a single JS file with a codebase above 1000 LOC!!!!)&lt;/li&gt;
&lt;li&gt;Modular programming keeps you from worrying about function scope and namespace. Because function names and scope becomes unique to the module they belong to.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s the basics of what modular programming and JavaScript is and what it can do for you.&lt;/p&gt;

&lt;h1&gt;
  
  
  WEBPACK
&lt;/h1&gt;

&lt;p&gt;Now have a basic understanding of what JavaScript modules are and why they are important, but how do you manage this modules? This is where webpack comes into the picture.&lt;/p&gt;

&lt;p&gt;webpack at it’s core is simply a module bundler.&lt;br&gt;
Module bundling involves webpack getting all your JavaScript modules and throwing them into one JavaScript file(that’s the bundling process!).&lt;/p&gt;

&lt;p&gt;webpack does this by creating a dependency graph for your project. The dependency graph keeps track of your project modules(different pieces) and their various dependencies(the other piece of your project code) and bundles them into one file(usually named bundle.js). This way webpack can easily keep track of your project modules and manages them for you.&lt;/p&gt;

&lt;p&gt;webpack has some other cool features aside bundling your JavaScript modules. webpack also helps you use the latest JavaScript features even when they are not supported by browsers(it achieves this by integrating babel-loaders into webpack configuration file). So that’s what webpack is, but to use webpack in project you need to understand some webpack core concepts.&lt;/p&gt;

&lt;h1&gt;
  
  
  WEBPACK CORE CONCEPTS
&lt;/h1&gt;

&lt;p&gt;This is no substitute to the original webpack core concepts found in the webpack documentation. So make sure to check it out.&lt;/p&gt;

&lt;h1&gt;
  
  
  ENTRY
&lt;/h1&gt;

&lt;p&gt;Entry is simply the point(the first JavaScript module) where webpack starts bundling your modules. View entry as the main door into a house, there are other doors in the house but to enter the house you have to use the main door.&lt;/p&gt;

&lt;p&gt;The entry is usually a JavaScript file where all the other modules and their various dependencies converge. webpack starts building the dependency graph from this file and locates the other dependencies of the other modules attached to the entry file.&lt;/p&gt;

&lt;h1&gt;
  
  
  OUTPUT
&lt;/h1&gt;

&lt;p&gt;Output is a path to a file where webpack throws all the bundled modules into.&lt;/p&gt;

&lt;p&gt;It will be good you know that the bundled modules is what is served to the browser and that is what you should add to your html file.&lt;/p&gt;

&lt;p&gt;bundle.js should be included in the script tag of your html file.&lt;/p&gt;

&lt;h1&gt;
  
  
  LOADERS
&lt;/h1&gt;

&lt;p&gt;Remember when i said webpack allows you to use language updated features that are not yet supported by browsers? loaders give webpack that superpower.&lt;/p&gt;

&lt;p&gt;loaders tells webpack how to handle or interact with files that are not JavaScript. Webpack is built with JavaScript and understands only JavaScript, but our project contains other files that are not JavaScript! loaders are there to solve this problem. See below for a few list of what loaders can help you do with webpack;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;loaders transforms files that are not JavaScript into JavaScript.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;loaders ( style-loaders) allows you to import your css styles into your JavaScript file which will ordinarily not be possible.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;loaders also helps your treat this none JavaScript files as modules too. the css-loaders allows you to write modular css for parts of your html file. Now instead of having one large css file file you can now have several modular css files for particular parts of your html code, also instead of linking the css link into your html file, style-loaders allows you to import this styles into your main.js file(the webpack entry file).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Loaders also allow you to use updated language features that are not supported in web browsers. Babel-loaders gives you the liberty to use the ES6 import and export(which supports modular programming in JavaScript) keyword that is yet to be supported in old browser version like IE, chrome version 50 below.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  PLUGINS
&lt;/h1&gt;

&lt;p&gt;plugins at its core basically add more functionality to your webpack compilation process. plugins helps you add custom built functionalities the webpack build process. Its more like plugins give webpack more superpowers during its build process.&lt;/p&gt;

&lt;p&gt;So that’s the basics of what modular programming, JavaScript modules, and webpack is. I hope you enjoyed it and now at least grasp all the concepts that were explained.&lt;/p&gt;

&lt;p&gt;In a bid not to make this boring and bulky, I decided to make this blog post modular, so I would be creating another module on how to include and configure webpack for your projects. See you in the next module.&lt;/p&gt;

</description>
      <category>webpack</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
