<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Programming for Everyone]]></title><description><![CDATA[Programming for Everyone]]></description><link>https://blog.lekan.dev</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Apr 2026 20:03:39 GMT</lastBuildDate><atom:link href="https://blog.lekan.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Starting Off: A Comprehensive Introductory Guide]]></title><description><![CDATA[you can easily tell from the title of this series; it gives a no-Nonsense Vibe.
Still, I will be leaving the intro as is right now and cycle back before the end of the week. I am really not in the mood for intros currently. excited to get my hands di...]]></description><link>https://blog.lekan.dev/starting-off</link><guid isPermaLink="true">https://blog.lekan.dev/starting-off</guid><dc:creator><![CDATA[Olalekan Abdulfatah]]></dc:creator><pubDate>Wed, 11 Oct 2023 09:50:07 GMT</pubDate><content:encoded><![CDATA[<p>you can easily tell from the title of this series; it gives a no-Nonsense Vibe.</p>
<p>Still, I will be leaving the intro as is right now and cycle back before the end of the week. I am really not in the mood for intros currently. excited to get my hands dirty... and with no plans.</p>
]]></content:encoded></item><item><title><![CDATA[AWS: A spaghetti bowl of services]]></title><description><![CDATA[Yes, you read right. AWS is a spaghetti in a bowl, a tangled array of services. it is a nightmare.In these recent times of software engineering, cloud computing has become an indispensable part of digital innovation, enabling businesses and developer...]]></description><link>https://blog.lekan.dev/aws-a-spaghetti-bowl-of-services</link><guid isPermaLink="true">https://blog.lekan.dev/aws-a-spaghetti-bowl-of-services</guid><category><![CDATA[AWS]]></category><category><![CDATA[Devops]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[technology]]></category><dc:creator><![CDATA[Olalekan Abdulfatah]]></dc:creator><pubDate>Fri, 06 Oct 2023 08:42:49 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1696581393173/3c3ef0a1-f381-4135-bbcd-50f04467783b.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Yes, you read right. AWS is a spaghetti in a bowl, a tangled array of services. it is a nightmare.<br />In these recent times of software engineering, <a target="_blank" href="https://www.oracle.com/ng/cloud/what-is-cloud-computing/">cloud computing</a> has become an indispensable part of digital innovation, enabling businesses and developers to achieve more with less. And in this said industry of cloud computing, AWS unmistakably stands out — not just for its dominance but for its intricate web of services.<br />Picture a colossal bowl of spaghetti, where each strand intertwines with another, representing a unique AWS service. At first glance, it's overwhelming, a veritable maze that seems impossible to untangle. But fear not! While AWS might seem like a nightmare with its vast array of options, this series aims to help you differentiate your EC2 from your S3, your Lambda from your DynamoDB. Join me on this journey as we attempt to unravel this complex dish, one strand at a time.</p>
<h2 id="heading-what-is-aws">What is AWS?</h2>
<p>From the <a target="_blank" href="https://aws.amazon.com/what-is-aws/">horse's</a> mouth himself, Amazon Web Services (AWS) is the world’s most comprehensive and broadly adopted cloud, offering over 200 fully featured services from data centers globally. Millions of customers—including the fastest-growing startups, largest enterprises, and leading government agencies—are using AWS to lower costs, become more agile, and innovate faster.</p>
<p>Yes, that kinda sounds like bragging. It is however true.</p>
<p>AWS, is the cloud services division of Amazon, providing on-demand computing resources and services in the cloud, on a pay-as-you-go basis. Introduced in 2006, AWS began with the simple idea of selling compute power and storage space on the Internet, eliminating the need for businesses and individuals to own and maintain their own <a target="_blank" href="https://10web.io/glossary/physical-server/">physical servers</a> and <a target="_blank" href="https://www.ibm.com/topics/data-centers">data centers</a>.</p>
<p>AWS's global infrastructure is built around regions and availability zones. Each region is a separate geographic location, and within each region, there are multiple isolated availability zones (AZs) — essentially data centers. This design ensures data redundancy, fault tolerance, and high availability, making it a reliable choice for businesses of all sizes.</p>
<h2 id="heading-why-aws">Why AWS?</h2>
<p>Amazon Web Services has firmly established itself as a frontrunner in the cloud computing world. But what factors contribute to its widespread adoption? why is it often the preferred choice amongst developers?</p>
<ol>
<li><p><strong>Pioneering Advantage:</strong> While AWS was made public as a cloud platform in 2006,it's jouney really began in 2002 primarily providing a few Web solutions and services designed specifically for developers and website owners. It wasn't just one of the first players in the cloud market; it essentially defined what cloud computing is today. AWS paved the way for the cloud revolution, enabling countless businesses to transform their operations and scale like never before.</p>
</li>
<li><p><strong>A vast array of Service Offerings:</strong> With over 200 fully featured services, No other provider can boast of offering that many services. the advantage of this is that businesses of all sizes and all sectors can definitely find tools that are specifically tailored to their needs.</p>
</li>
<li><p><strong>Security:</strong> AWS is built and maintained with a core focus on security. It provides tools and guidelines/practices for ensuring data protection, Identity Management (IAM), and compliance. if you have ever been hacked, you will understand the importance of this.</p>
</li>
<li><p><strong>Community and support:</strong> I love this one. The reason why Javascript seems easy is because of its popularity and huge community, you need to learn anything in javascript? someone has made a tutorial about it. You need to carry out a daunting task? best believe someone has made a library that makes your job way easier.<br /> AWS has a vibrant community of users, developers, and advocates. The vast array of documentation, tutorials, and training programs like AWS Certifications ensures continuous learning and support.</p>
</li>
<li><p><strong>Flexible Pricing:</strong> With its pay-as-you-go pricing model, you can start small, scale resources based on demand, and only pay for what you use thus avoiding hefty upfront costs.</p>
</li>
<li><p><strong>Global:</strong> their infrastructure spans multiple regions across the globe, ensuring high availability and fault tolerance. Each region has multiple <a target="_blank" href="https://wa.aws.amazon.com/wellarchitected/2020-07-02T19-33-23/wat.concept.az.en.html">availability zones</a> (AZs), effectively reducing <a target="_blank" href="https://aws.amazon.com/what-is/latency/">latency</a> and enhancing the user experience for global audiences. Low latency in itself is very important as, despite a well-optimized website, high latency can reduce page loading speed, potentially increasing churn rates.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1696581205693/b48be63b-edc6-492c-b955-eff18020746b.png" alt class="image--center mx-auto" /></p>
</li>
</ol>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">Representation of AWS's Global Network</div>
</div>

<p>In essence, while there are several cloud providers offering valuable services, AWS's combination of breadth, depth, security, and innovation positions it uniquely in the cloud ecosystem. Whether you're a budding startup, a tech giant, or somewhere in between, AWS provides the tools and flexibility to build, innovate, and scale.</p>
<h2 id="heading-looking-ahead">Looking Ahead</h2>
<p>With the expansive nature of AWS, this introduction merely scratches the surface. As we venture deeper into the AWS universe in this series, we'll break down its vast offerings, making them digestible and relatable. Stay tuned as we embark on this cloud journey together, unraveling the complexities of AWS and making the most of its vast potential.</p>
]]></content:encoded></item><item><title><![CDATA[Leet2038: Remove Colored Pieces]]></title><description><![CDATA[Intro
In this article, we tackle Leet2038 here like Casemiro tackled Bruno Fernandes two weeks ago (or years ago depending on when you're reading this 😂😂😂). The problem presents a gaming scenario where we're given a sequence of game pieces/items, ...]]></description><link>https://blog.lekan.dev/leet2038-remove-colored-pieces</link><guid isPermaLink="true">https://blog.lekan.dev/leet2038-remove-colored-pieces</guid><category><![CDATA[leetcode]]></category><category><![CDATA[leetcode-solution]]></category><category><![CDATA[string]]></category><category><![CDATA[game]]></category><category><![CDATA[leetcode 2038]]></category><dc:creator><![CDATA[Olalekan Abdulfatah]]></dc:creator><pubDate>Mon, 02 Oct 2023 15:53:05 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1696243731005/fec8200f-2d9d-48fd-b6d2-efed6adf1023.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-intro">Intro</h2>
<p>In this article, we tackle Leet2038 <a target="_blank" href="https://leetcode.com/problems/remove-colored-pieces-if-both-neighbors-are-the-same-color/description/">here</a> like Casemiro tackled Bruno Fernandes two weeks ago (or years ago depending on when you're reading this 😂😂😂). The problem presents a gaming scenario where we're given a sequence of game pieces/items, each colored either 'A' or 'B'. Imagine a board game between Alice and Bob, where they take turns removing pieces based on certain rules. The goal of Leet2038 is simple: determine who wins this delightful game! Alice? Bob?<br />The problem is a kind of weird one. Weird because it is actually quite easy to implement. It does not build on any complex algorithmic pattern or data structures. I think, literally the barest minimum of programming knowledge is required to solve this. However, it is very easy to overcomplicate the problem and get stuck especially since it is tagged a <code>medium</code> difficulty. I know I did.</p>
<h2 id="heading-problem-statement">Problem Statement</h2>
<p>There are <code>n</code> pieces arranged in a line and each piece is colored either by <code>'A'</code> or by <code>'B'</code>. You are given a string <code>colors</code> of length <code>n</code> where <code>colors[i]</code> is the color of the <code>i&lt;sup&gt;th&lt;/sup&gt;</code> piece.</p>
<p>Alice and Bob are playing a game where they take <strong>alternating turns</strong> removing pieces from the line. In this game, Alice moves <strong>first</strong>.</p>
<ul>
<li><p>Alice is only allowed to remove a piece colored <code>'A'</code> if <strong>both its neighbors</strong> are also colored <code>'A'</code>. She is <strong>not allowed</strong> to remove pieces that are colored <code>'B'</code>.</p>
</li>
<li><p>Bob is only allowed to remove a piece colored <code>'B'</code> if <strong>both its neighbors</strong> are also colored <code>'B'</code>. He is <strong>not allowed</strong> to remove pieces that are colored <code>'A'</code>.</p>
</li>
<li><p>Alice and Bob <strong>cannot</strong> remove pieces from the edge of the line.</p>
</li>
<li><p>If a player cannot make a move on their turn, that player <strong>loses</strong> and the other player <strong>wins</strong>.</p>
</li>
</ul>
<p>Assuming Alice and Bob play optimally, return <code>true</code> <em>if Alice wins, or return</em> <code>false</code> <em>if Bob wins</em>.</p>
<h2 id="heading-initial-thought">Initial Thought</h2>
<p>We will skip this, it's embarrassing. I was actually stuck because I started thinking of how to track how many times Bob can possibly win individually (i.e how many times we have a substring of 3 consecutive Bs, and what happens when have 4, 5,...+ Bs), and how many times Alice can possibly win individually. maybe that could work but It was evident after some minutes that it was after all an overkill and would be tricky to implement even if it could work.<br />how do we solve it then?<br />1. I reread and tried to simplify the question so I could completely understand it.<br />2. I walked through the test cases manually without writing down any code<br />3. I realized it has a lot to do with sequencing. so, I decided; solve an easy Leet whatever that implements sequencing, let's call that a detour.</p>
<h2 id="heading-the-detour">The Detour</h2>
<p><strong><mark><s>Problem Statement:</s></mark></strong><mark><s><br />Given a binary array </s></mark> <code>nums</code><mark><s>, return </s></mark> <em><mark><s>the maximum number of consecutive </s></mark></em> <code>1</code><em><mark><s>'s in the array</s></mark></em><mark><s>.</s></mark></p>
<p><strong><mark><s>Example</s></mark></strong></p>
<pre><code class="lang-markdown">Input: nums = [1,1,0,1,1,1]
Output: 3
Explanation: The first two digits or the last three digits are 
consecutive 1s. The maximum number of consecutive 1s is 3.
</code></pre>
<p><strong><mark><s>Solution:</s></mark></strong><mark><s><br /></s></mark></p>
<pre><code class="lang-go"><span class="hljs-keyword">import</span> <span class="hljs-string">"math"</span>

<span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">findMaxConsecutiveOnes</span><span class="hljs-params">(nums []<span class="hljs-keyword">int</span>)</span> <span class="hljs-title">int</span></span> {
  <span class="hljs-comment">/**
    * who would have thought the problem was this easy. 
    * so, you mean that I only have to count ones.
    * loop though, if it is a one, add it to the curr
    * else, reset curr to zero until we find a one again 
    */</span>
    max ,curr := <span class="hljs-number">0</span>,<span class="hljs-number">0</span>;

    <span class="hljs-keyword">for</span> _,num := <span class="hljs-keyword">range</span> nums{
        <span class="hljs-keyword">if</span> num == <span class="hljs-number">1</span>{
            curr++
        }<span class="hljs-keyword">else</span>{
            max = <span class="hljs-keyword">int</span>(math.Max(<span class="hljs-keyword">float64</span>(max), <span class="hljs-keyword">float64</span>(curr)))
            curr=<span class="hljs-number">0</span>
        }
    }
    max = <span class="hljs-keyword">int</span>(math.Max(<span class="hljs-keyword">float64</span>(max), <span class="hljs-keyword">float64</span>(curr)))
    <span class="hljs-keyword">return</span> max;    
}
</code></pre>
<p><mark><s>this problem had to do with counting number of similar elements except this problem is even a little more complex because now, we have to know when to reset the current counts</s></mark></p>
<h2 id="heading-my-approach">My Approach</h2>
<p>Let's read the problem again because really, that is the only difficult part.<br /><strong>Givens:</strong><br />1. Alice can only remove a piece provided both its neighbors are the same. I.E '<code>AAA</code>'<br />2. Bob can only remove a piece if both its neighbors are the same. I.E '<code>BBB</code>'</p>
<p>what the above might tell us is that we have to loop through the string and check at every point in time if we have 3 consecutive colors. (think of what that logic will look like in your head. <code>i-1</code> , <code>i</code> and <code>i+1</code> right? yh, you might be right.)<br />but.....</p>
<p>3. What if we have an instance where we have 4 consecutive? (<code>'AAAA'</code>).<br />hmmm. well, it barely matters because we only need to know and worry about checking that there will be 3 consecutive <code>AAA</code>, and if we move to the next iteration, We verify this condition AGAIN, which signals that we can perform two removals consecutively from that position. and that is accurate for 4 consecutive <code>A</code>s. The same logic works if there are even more.<br />Counting the occurrences essentially tells us how many times a player can make a move in the game, independently of whether there's another player or not.</p>
<p>4. A player cannot remove pieces at the edge, sweet. I guess we better start counting from index 1 and end at (<code>index array.length -2</code>). This also tells us the least length of the array we can possibly get us 2. I guess 🤡.</p>
<ol>
<li>Alice plays first. so, if they both end up with an equal number of moves, Alice loses. I really should not have to explain that part.</li>
</ol>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">To Summarize, the trick behind solving this problem is looking for how many moves either of them possibly have. and because Alice played first, Alice must have a higher number to win. else she loses.</div>
</div>

<h2 id="heading-implementation">Implementation</h2>
<p>solving this in go since it is quite straightforward</p>
<pre><code class="lang-go"><span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">winnerOfGame</span><span class="hljs-params">(colors <span class="hljs-keyword">string</span>)</span> <span class="hljs-title">bool</span></span> {
     aCount := <span class="hljs-number">0</span>  <span class="hljs-comment">// Count of consecutive 'A's</span>
    bCount := <span class="hljs-number">0</span>  <span class="hljs-comment">// Count of consecutive 'B's</span>
    n := <span class="hljs-built_in">len</span>(colors)

    <span class="hljs-comment">// Iterate through the colors and count consecutive 'A's and 'B's</span>
    <span class="hljs-comment">// we start iteration from 1 and end at i == len(colors)-2;</span>
    <span class="hljs-keyword">for</span> i := <span class="hljs-number">1</span>; i &lt; n<span class="hljs-number">-1</span>; i++ {
        <span class="hljs-keyword">if</span> colors[i] == <span class="hljs-string">'A'</span> {
            <span class="hljs-keyword">if</span> colors[i<span class="hljs-number">-1</span>] == <span class="hljs-string">'A'</span> &amp;&amp; colors[i+<span class="hljs-number">1</span>] == <span class="hljs-string">'A'</span> {
                aCount++
            }
        } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> colors[i] == <span class="hljs-string">'B'</span> {
            <span class="hljs-keyword">if</span> colors[i<span class="hljs-number">-1</span>] == <span class="hljs-string">'B'</span> &amp;&amp; colors[i+<span class="hljs-number">1</span>] == <span class="hljs-string">'B'</span> {
                bCount++
            }
        }
    }

    <span class="hljs-comment">// Alice wins if she can make more moves than Bob</span>
    <span class="hljs-keyword">return</span> aCount &gt; bCount
}
</code></pre>
<h2 id="heading-complexity-analysis">Complexity Analysis</h2>
<p>Nothing to analyze here<br />Time complexity: O(n) ~ Linear<br />Space Complexity: O(1) Constant</p>
<h2 id="heading-takeaways-lessons">Takeaways/ Lessons</h2>
<p>This question really tests how you can convert business logic into code and simplify problems. It really is a simple problem and you would easily be wasting company's time and resources if you are unable to see that<br />Also, don't jump heading into solving questions. when stuck, try to solve manually with test cases and not programmatically.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In tackling Leet2038, we've learned that even seemingly simple problems can test our ability to simplify and implement business logic effectively. The key is recognizing the essence of the problem and avoiding unnecessary complexity. The essence was simply who wins. every other variable (E.G how many times a player can remove from a consecutive subsequence) is unnecessary if they do not help us achieve our result.</p>
]]></content:encoded></item><item><title><![CDATA[Leet389: Find The Difference.]]></title><description><![CDATA[Intro
You very likely missed the intro article A.K.A disclaimer, to this series but here goes. This is the first actual article with real content (for this series) and, we are tackling an easy leetcode problem, I attempted the champagne glass that wa...]]></description><link>https://blog.lekan.dev/leet389-find-the-difference</link><guid isPermaLink="true">https://blog.lekan.dev/leet389-find-the-difference</guid><category><![CDATA[learning]]></category><category><![CDATA[find the differences]]></category><category><![CDATA[leetcode]]></category><category><![CDATA[problem of the day]]></category><dc:creator><![CDATA[Olalekan Abdulfatah]]></dc:creator><pubDate>Tue, 26 Sep 2023 06:02:16 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1695708738806/339ba309-5cc0-403c-9086-c4e7b4578735.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-intro">Intro</h3>
<p>You very likely missed the intro article A.K.A disclaimer, to this series but <a target="_blank" href="https://blog.lekan.dev/writing-is-hard">here goes</a>. This is the first actual article with real content (for this series) and, we are tackling an easy leetcode problem, I attempted the champagne glass that was the "problem of the day" prior. Let's just say it didn't go as planned 😄. #chucklingEmoji.</p>
<p>While today's problem might have real-world applications, I don't know what they are yet so, we'll focus on understanding and solving it for now. Grab your favorite bodysuit and let's dive in.</p>
<h3 id="heading-problem-statement">Problem Statement</h3>
<p>You are given two strings <code>s</code> and <code>t</code>.</p>
<p>String <code>t</code> is generated by randomly shuffling string <code>s</code> and then adding one more letter at a random position.</p>
<p>Return the letter that was added to <code>t</code>.</p>
<h3 id="heading-initial-thought">Initial Thought</h3>
<p>Clearly, this is a problem where you have to iterate through a string and try to decipher if you have seen that string before. we all know, at least I know, that the general approach to that, that will lead to a linear time complexity is to introduce a hash map data structure. (Because well, fast lookup).<br />That part is obvious. where you might start to go wrong is using a test case of short strings. that way, it won't be obvious that you only have 26 alphabets in the English language and you might need to track the frequency of appearance,<br />my initial approach was to use the hash map and map a key of the alphabet to true showing that I had seen it before.<br />what happens when an alphabet shows up the 2nd, or 3rd..... time? Now you can see how that approach is wrong right?</p>
<h3 id="heading-actual-approach">Actual Approach</h3>
<p>Givens:<br />1. we need to use an hash map to keep track of the letters.<br />2. We need to also record the frequency of seeing it. How many times Have I seen this letter?<br />you might start to wake up now, if we were given a string s that has 10 letters, and t with 11 letters, clearly if we store both in separate maps and compare, whatever key in the map that has 1 more than the same key in the other map is the answer.</p>
<p>Arrgh, I didn't want to have to illustrate this but...</p>
<pre><code class="lang-javascript">s= <span class="hljs-string">"abcdefde"</span> t= <span class="hljs-string">"cdeabdzef"</span> <span class="hljs-comment">//you can see that we added z right?</span>
<span class="hljs-comment">//now, the map looks something like this</span>
sMap ={<span class="hljs-attr">a</span>:<span class="hljs-number">1</span>,<span class="hljs-attr">b</span>:<span class="hljs-number">1</span>,<span class="hljs-attr">c</span>:<span class="hljs-number">1</span>,<span class="hljs-attr">d</span>:<span class="hljs-number">2</span>,<span class="hljs-attr">e</span>:<span class="hljs-number">2</span>,}
tMap={<span class="hljs-attr">a</span>:<span class="hljs-number">1</span>,<span class="hljs-attr">b</span>:<span class="hljs-number">1</span>,<span class="hljs-attr">c</span>:<span class="hljs-number">1</span>,<span class="hljs-attr">d</span>:<span class="hljs-number">2</span>,<span class="hljs-attr">e</span>:<span class="hljs-number">2</span>, <span class="hljs-attr">z</span>:<span class="hljs-number">1</span>}
</code></pre>
<p>looking at the map, the answer is obvious right ?Z. but getting the answer programmatically might be a bit tricky. so, instead of using 2 separate maps, why not 1 right? and as we have populated the tMap using the string <code>t</code>, we can depopulate it in the same vain as the <code>s</code> string until everything defaults back to 0, and z becomes 1. Now, we can loop through the object and look for the key that has a value of 1. There goes our answer. we can do it the other way round too.</p>
<h3 id="heading-implementation">Implementation</h3>
<pre><code class="lang-typescript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">findTheDifference</span>(<span class="hljs-params">s: <span class="hljs-built_in">string</span>, t: <span class="hljs-built_in">string</span></span>): <span class="hljs-title">string</span> </span>{
    <span class="hljs-keyword">const</span> map = {};
    <span class="hljs-keyword">for</span>(<span class="hljs-keyword">const</span> char <span class="hljs-keyword">of</span> t){
        map[char] = (map[char]?? <span class="hljs-number">0</span>)+<span class="hljs-number">1</span>
    }
    <span class="hljs-keyword">for</span>(<span class="hljs-keyword">const</span> char <span class="hljs-keyword">of</span> s){
        <span class="hljs-comment">// I expect to always have at least 1 map[char]</span>
        map[char] = map[char] <span class="hljs-number">-1</span>;
    }
    <span class="hljs-keyword">for</span>(<span class="hljs-keyword">const</span> key <span class="hljs-keyword">in</span> map){
        <span class="hljs-keyword">if</span>(map[key] ===<span class="hljs-number">1</span>)<span class="hljs-keyword">return</span> key
    }
};
</code></pre>
<p>Perhaps, we should solve this in go too. flexing my beginner go-lang skills. (I don't like yet that there is strings and there is byte in Go. can't we just stick with strings only? I'll get to understand the benefits later though). at least, I definitely love that for loops and while loops have the same syntax.</p>
<pre><code class="lang-go"><span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">findTheDifference</span><span class="hljs-params">(s <span class="hljs-keyword">string</span>, t <span class="hljs-keyword">string</span>)</span> <span class="hljs-title">byte</span></span> {
   myMap := <span class="hljs-built_in">make</span>(<span class="hljs-keyword">map</span>[<span class="hljs-keyword">rune</span>]<span class="hljs-keyword">int</span>) 
<span class="hljs-comment">//here, we used a type of rune instead of string or byte.</span>
<span class="hljs-comment">// why? that is a task for the reader</span>

   <span class="hljs-keyword">for</span> _,char := <span class="hljs-keyword">range</span> t{
    <span class="hljs-comment">//unlike JS, we can do this in go because it will default the value </span>
    <span class="hljs-comment">//to zero since it knows it is to be an integer. </span>
    <span class="hljs-comment">//we don't have to manually default it ourselves. </span>
      myMap[char] = myMap[char]+ <span class="hljs-number">1</span>
   }

   <span class="hljs-keyword">for</span> _,char := <span class="hljs-keyword">range</span> s{
       myMap[char] =  myMap[char] <span class="hljs-number">-1</span>
   }

   <span class="hljs-keyword">for</span> key, val := <span class="hljs-keyword">range</span> myMap{
       <span class="hljs-keyword">if</span> val == <span class="hljs-number">1</span>{
           <span class="hljs-keyword">return</span> <span class="hljs-keyword">byte</span>(key)
       }
   }

   <span class="hljs-keyword">return</span> <span class="hljs-string">'a'</span>
}
</code></pre>
<h3 id="heading-complexity-analysis">Complexity Analysis</h3>
<p>in our approach, the maximum size of our map is 26. since we are only dealing with 26 English alphabets. that is constant space.<br />for time, we iterate through the s and t strings once each and once through the map, that is 0(n+m) + 0(1). simplified to 0(n).<br />Time complexity: linear<br />space complexity: Constant</p>
<h3 id="heading-lesson-learned">Lesson Learned</h3>
<p>Well, I learned why you use a rune type instead of string or byte for situations like when I initialized myMap in the go solution. <code>myMap := make(map[rune]int)</code><br />It is the reader's responsibility to find out why</p>
<h3 id="heading-other-approaches">Other Approaches</h3>
<p>There is the Ascii method where you convert the letters to Ascii numbers and add them all up. s is added separately, and so is t. then, subtracted from each other. the difference gives a corresponding English alphabet. however, I do not like this approach, it is certainly faster because working with numbers is faster for computers, but imagine a scenario where 2 letters were added, you can see the ASCII method might become useless or more difficult to implement. exactly. stick with the mapping method.</p>
<h3 id="heading-real-world-applications">Real World Applications.</h3>
<p>I think it is very similar to ceaser cipher which is a very old method of encryption.<br />That is all I know</p>
<h3 id="heading-conclusion">Conclusion</h3>
]]></content:encoded></item><item><title><![CDATA[Article Writing is Hard !!!]]></title><description><![CDATA[Okay, maybe not that hard to be honest. If you fully understand the topic you're writing about, you simply pour it into text, throw in some images to illustrate your haphazarded mind, structure your thoughts, ensure you're conveying a message, add a ...]]></description><link>https://blog.lekan.dev/writing-is-hard</link><guid isPermaLink="true">https://blog.lekan.dev/writing-is-hard</guid><category><![CDATA[data structures]]></category><category><![CDATA[leetcode]]></category><category><![CDATA[algorithms]]></category><category><![CDATA[coding challenge]]></category><category><![CDATA[coding]]></category><dc:creator><![CDATA[Olalekan Abdulfatah]]></dc:creator><pubDate>Mon, 25 Sep 2023 07:23:23 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1695626471186/9e9210cb-f8d4-402d-a787-f287bf490bf0.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Okay, maybe not that hard to be honest. If you fully understand the topic you're writing about, you simply pour it into text, throw in some images to illustrate your haphazarded mind, structure your thoughts, ensure you're conveying a message, add a conclusion, and voilà, you hit publish. Tu vois? Ce n'est pas si compliqué.</p>
<p>You can already start to notice the problem. While it might not be that hard to put your thoughts in an article, it can be daunting and time-consuming to create one that you consider satisfactory. oui oui?</p>
<p>Still, that's not exactly a problem that can't be dealt with. After all, Whatever is worth doing at all is worth doing well. Well, Except, I do NOT own that kind of time.🤡</p>
<p>Hehehe!!! This series is strictly a learning process for me. It's to reinforce new ideas and concepts I've learned by re-explaining them and putting them down so I can think more deeply about them as I do so. <strong>Hence, the quality of the write-ups will very likely be subpar,</strong> but they will achieve their purpose: [ME!].</p>
<h3 id="heading-what-to-expect">What to Expect</h3>
<p>I aim to publish a new article every day, (Don't be surprised if I'm only able to write one each week though). stay tuned for daily updates anyway!</p>
<h3 id="heading-your-feedback-matters">Your Feedback Matters</h3>
<p>Feel free to leave comments or questions. Your input can help me correct mistakes for myself and fill knowledge gaps. it will also help me refine the series and make it more useful for everyone.</p>
]]></content:encoded></item><item><title><![CDATA[JavaScript Enigmas: Cracking Closures]]></title><description><![CDATA[Closures, Closures, Closures !!!!🤔
If you've ever felt puzzled by closures in JavaScript, you're in good company. You could be using closures every day in your code and not even know it! Yep, true story. Believe it or not, I once aced a closure-base...]]></description><link>https://blog.lekan.dev/javascript-enigmas-cracking-closures</link><guid isPermaLink="true">https://blog.lekan.dev/javascript-enigmas-cracking-closures</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[javascript concepts]]></category><category><![CDATA[lexical environment]]></category><category><![CDATA[closures in javascript]]></category><category><![CDATA[Closures]]></category><dc:creator><![CDATA[Olalekan Abdulfatah]]></dc:creator><pubDate>Thu, 07 Sep 2023 10:57:59 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1694083540743/7b41a905-7f20-4310-ac67-2dcdc8ee9349.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Closures, Closures, Closures !!!!🤔</p>
<p>If you've ever felt puzzled by closures in JavaScript, you're in good company. You could be using closures every day in your code and not even know it! Yep, true story. Believe it or not, I once aced a closure-based interview question without fully understanding what closures were. However, understanding closures can significantly elevate your coding skills.</p>
<h2 id="heading-what-is-closure-in-javascript">#What is Closure in Javascript ?</h2>
<p><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures">MDN</a> says "A <strong>closure</strong> is the combination of a function bundled together (enclosed) with references to its surrounding <a target="_blank" href="https://en.wikipedia.org/wiki/State_(computer_science)">state</a> (the <strong>lexical environment</strong>). In other words, a closure gives you access to an outer function's scope from an inner function."</p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">👀</div>
<div data-node-type="callout-text">I don't know about you but that definition is a little too tricky for me to understand.</div>
</div>

<p>Maybe we still can't define what closure is yet. We can at least agree that it is enclosed in some form of container called the Lexical environment, it also has something to do with functions bundled together with something about references.</p>
<p>What then is a lexical environment?<br />Clearly, we have to understand some basic concepts first before delving into closure itself as a concept.</p>
<h3 id="heading-concepts-around-closure">Concepts around closure</h3>
<p><strong>Concept #1: Scoping / Lexical scoping.</strong><br />Scoping simply means the locations a declared variable has "access" to and the lexical behind it tells you that the scope of a variable is determined based on its location in the source code.<br />In JavaScript, especially modern javascript, where you declare your variables matter. like, a lot! Variables defined in a function are not accessible outside of it, but they are accessible to functions nested/ <em>inside</em> that function.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> bookName = <span class="hljs-string">"readings"</span>;

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getAuthorName</span>(<span class="hljs-params"></span>)</span>{
<span class="hljs-keyword">const</span> author = <span class="hljs-string">"Ajayi"</span>;
<span class="hljs-built_in">console</span>.log(author, bookName); <span class="hljs-comment">//"Ajayi readings"</span>

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">nestedFunction</span>(<span class="hljs-params"></span>)</span>{
    <span class="hljs-comment">//has access to variable declared in the parent function</span>
    <span class="hljs-comment">// also has acess to global variables. E.G bookName</span>
}
<span class="hljs-keyword">return</span> author;
}

<span class="hljs-built_in">console</span>.log(bookName) <span class="hljs-comment">//"readings"</span>
<span class="hljs-built_in">console</span>.log(author) <span class="hljs-comment">//Uncaught ReferenceError: author is not defined</span>
</code></pre>
<p>As explained earlier, where you declare your variables matter in JavaScript because the scopes of these variables are created based on their location in the source code.<br />The rule is simple.</p>
<blockquote>
<p>Variables defined with "let" or "const" within a block of code are only accessible within that block.</p>
</blockquote>
<p>Hence, it is easy to understand why <code>author</code> and <code>bookname</code> in the example above are accessible within the function <code>getAuthorName</code> but trying to access <code>author</code> outside of the function throws an error.</p>
<p><strong>Concept #2:</strong> <strong>Block Scoping, Functional Scoping, Global Scoping, and the Story of</strong> <code>const</code> <strong>,</strong><code>let</code> <strong>and</strong> <code>var.</code><br />This is a topic that deserves its own stage, but let's do a quick fly-by.</p>
<ul>
<li><p><strong>Block Scoping</strong>: Variables declared with <code>let</code> and <code>const</code> stick to their block. It's just the modern way of doing things.</p>
</li>
<li><p><strong>Functional Scoping</strong>: <code>var</code> is the OG here and it lives within the function it's declared in. It transcends the block scoping.</p>
</li>
<li><p><strong>Global Scoping:</strong> Variables in the global scope are not declared within any block or functions, they can be accessed anywhere in the code.</p>
</li>
<li><p><code>const</code> <strong>vs</strong> <code>let</code> <strong>vs</strong> <code>var</code>: Use <code>const</code> for constants, <code>let</code> for reassignable variables, and <code>var</code>... well, mostly avoid. 🤷‍♂️</p>
</li>
</ul>
<p>For a deep dive into this, check out <a target="_blank" href="https://www.geeksforgeeks.org/difference-between-var-let-and-const-keywords-in-javascript/">this article</a> that explains it all. Don't worry, I'll tackle this head-on in a future article!</p>
<p><strong>Concept #3: Lexical environment</strong><br />This is the tricky bit and it is quite theoretical in its own right. let me try to explain with a simple analogy.</p>
<p>Imagine you're a detective, and you're trying to find clues to solve a case. The place you'd look for these clues first is where the incident has happened (the crime scene), then you might find clues that lead you to look outside of that immediate environment. somewhere outside of the scene. The scene is the lexical environment. In JavaScript, a Lexical Environment exists for each block of code, each function, and yes, even for the global context that runs. Each lexical environment has two parts:</p>
<ol>
<li><p><strong>Environment Record</strong>: This is the abstract location in which something has happened in code. E.G. a function call. It stores all the variables and declarations in that function.</p>
</li>
<li><p><strong>Reference to Outer Environment</strong>: Don't you love it when you're not confined within your space? same for our environment too. The environment likes to keep a reference to the Lexical Environment of the parent scope, parent parent scope, or global scope. You get the idea. It keeps a reference to the outer environments it will have access to.<br /> Here's a quick example to quench your cravings for some lines of code.</p>
</li>
</ol>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> city = <span class="hljs-string">"Gotham"</span>;

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">batSignal</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">let</span> message = <span class="hljs-string">"Bat Signal activated in "</span> + city;
  <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">displaySignal</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-built_in">console</span>.log(message); <span class="hljs-comment">// "Bat Signal activated in Gotham"</span>
  }
  displaySignal();
}

batSignal();
</code></pre>
<p>In this example, the function <code>displaySignal()</code> is nested inside <code>batSignal()</code> making it a Lexical Environment within another Lexical Environment - remember every function has its own Lexical Environment? When <code>displaySignal()</code> wants to print <code>message</code>, it first checks its own Environment Record (nope, not here!), and then the Reference to the Outer Environment kicks in, leading it to find <code>message</code> in <code>batSignal()</code>'s environment, a parent environment. 🦇 Kapish!!!</p>
<p>Perhaps now, MDN's definition will start to make sense. A closure, being a combination of a function with reference to.....</p>
<p><strong>Concept #4: The Beast; Closures.</strong><br />Remember when we talked about Lexical Environments? Good, because closures are like little minions that carry their own Lexical Environment wherever they go. Let me spill the tea.</p>
<p>A closure is a JavaScript function that <strong>remembers</strong> its <strong>outer variables</strong> even after the outer function has "returned" or after it has been "dissipated". In simpler terms, closures are functions that "remember" the environment in which they were created. 🤔<br />Let's take our next illustration from Leetcode. The <a target="_blank" href="https://leetcode.com/problems/counter/">createCounter</a> question.</p>
<pre><code class="lang-javascript"><span class="hljs-comment">//Given an integer n, return a counter function. This counter function </span>
<span class="hljs-comment">//initially returns n and then returns 1 more than the previous</span>
<span class="hljs-comment">//value every subsequent time it is called (n, n + 1, n + 2, etc).</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">createCounter</span>(<span class="hljs-params">n</span>) </span>{
  <span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">return</span> n++;
  };
}

<span class="hljs-comment">// Example usage</span>
<span class="hljs-keyword">const</span> counter = createCounter(<span class="hljs-number">10</span>);
<span class="hljs-built_in">console</span>.log(counter()); <span class="hljs-comment">// 10</span>
<span class="hljs-built_in">console</span>.log(counter()); <span class="hljs-comment">// 11</span>
<span class="hljs-built_in">console</span>.log(counter()); <span class="hljs-comment">// 12</span>
</code></pre>
<p>Here, <code>counter</code> is a closure because every time you call it, it still knows the latest value of n and still has the ability to update it</p>
<p><strong>How It Works 🧙‍♀️</strong></p>
<ol>
<li><p><code>createCounter(n)</code> returns a function (anonymous function). That function remembers the state of <code>n</code> even after <code>createCounter</code> has finished its execution. why? reference to outer lexical environments.</p>
</li>
<li><p>Each time the returned function <code>counter</code> is called, it returns the current value of <code>n</code> and then increments it by 1 using the post-increment operator (<code>n++</code>)<br /> and that my friends, is how closures work. The returned function, which is the closure is like a minion that goes about with its own suitcase containing its own lexical environment and references to outer environments that scoping has allowed it access to.</p>
</li>
</ol>
<h2 id="heading-the-nitty-gritty-specific-use-cases-for-closures"><strong>The Nitty-Gritty: Specific Use-Cases for Closures</strong></h2>
<p><strong>Use-Case #1: The Vault</strong><br />JavaScript objects are wide open by default and can be manipulated at will. but you don't always want that. Sometimes, you want to create a vault that not everyone has access to and then keep your secret variables there. You see, before the introduction of classes and private variables in Javascript, Closures were a way of keeping variables private within a function so that only methods within that function have access to retrieving or changing their value.</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">createBankAccount</span>(<span class="hljs-params">initialDeposit</span>) </span>{
  <span class="hljs-keyword">let</span> balance = initialDeposit;
  <span class="hljs-keyword">return</span> {
    <span class="hljs-attr">deposit</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">amount</span>) </span>{
      balance += amount;
      <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Deposited <span class="hljs-subst">${amount}</span>. Current balance: <span class="hljs-subst">${balance}</span>`</span>);
    },
    <span class="hljs-attr">withdraw</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">amount</span>) </span>{
      <span class="hljs-keyword">if</span> (amount &gt; balance) {
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Insufficient funds'</span>);
      } <span class="hljs-keyword">else</span> {
        balance -= amount;
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Withdrew <span class="hljs-subst">${amount}</span>. Current balance: <span class="hljs-subst">${balance}</span>`</span>);
      }
    }
  };
}

<span class="hljs-keyword">const</span> myAccount = createBankAccount(<span class="hljs-number">1000</span>);
myAccount.deposit(<span class="hljs-number">200</span>); <span class="hljs-comment">// You can do this!</span>
myAccount.withdraw(<span class="hljs-number">500</span>); <span class="hljs-comment">// And this!</span>
<span class="hljs-built_in">console</span>.log(myAccount.balance); <span class="hljs-comment">// But not this, Error!</span>
</code></pre>
<p>In the code above, <code>balance</code> is a private variable that can't be accessed directly from outside the <code>createBankAccount</code> function. It can only be modified using the <code>deposit</code> and <code>withdraw</code> methods. why? aha! You should already know. because <code>deposit</code> and <code>withdraw</code> are closures. They are the only ones who still remember the value of balance even after the function <code>createBankAccount</code> has been executed and forgotten about.</p>
<p><strong>Use-Case #2: Time Traveller; the secure timekeeper.</strong></p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">launchSequence</span>(<span class="hljs-params">start</span>) </span>{
  <span class="hljs-keyword">let</span> count = start;
  <span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"T-minus "</span> + count);
    count--;
  }
}

<span class="hljs-keyword">const</span> countdown = launchSequence(<span class="hljs-number">10</span>);

<span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">0</span>; i &lt;= <span class="hljs-number">10</span>; i++) {
  <span class="hljs-built_in">setTimeout</span>(<span class="hljs-function">() =&gt;</span> {
    countdown();
  }, i * <span class="hljs-number">1000</span>);
}
</code></pre>
<p>You can use closures to create timekeeping functions that cannot be tampered with from the outside world.<br />Here, <code>countdown</code> is a closure. It's carrying <code>count</code> from <code>launchSequence()</code> with it. Every time you call <code>countdown()</code>, it still knows what <code>count</code> is and updates it. <code>countdown()</code> carries its own supply of reference to <code>count</code> in its little briefcase</p>
<p><strong>use-case #3: The Function Industry. We make food and we make functions.</strong><br />Imagine you're operating a food truck. You've got your menu, but you also allow customers to customize their sandwiches. You need a way to easily produce variations of your menu items.</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">sandwichMaker</span>(<span class="hljs-params">fillings</span>) </span>{
  <span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">breadType</span>) </span>{
    <span class="hljs-keyword">return</span> <span class="hljs-string">`Here's your <span class="hljs-subst">${fillings}</span> sandwich on <span class="hljs-subst">${breadType}</span> bread!`</span>;
  }
}

<span class="hljs-keyword">const</span> makeChickenSandwich = sandwichMaker(<span class="hljs-string">"chicken"</span>);
<span class="hljs-keyword">const</span> makeVeggieSandwich = sandwichMaker(<span class="hljs-string">"veggie"</span>);

<span class="hljs-built_in">console</span>.log(makeChickenSandwich(<span class="hljs-string">"sourdough"</span>)); <span class="hljs-comment">// "Here's your chicken sandwich on sourdough bread!"</span>
<span class="hljs-built_in">console</span>.log(makeVeggieSandwich(<span class="hljs-string">"rye"</span>)); <span class="hljs-comment">// "Here's your veggie sandwich on rye bread!"</span>
</code></pre>
<p>here, <code>sandwichMaker</code> is a function that takes a filling (like "chicken" or "veggie") and returns another function. The returned function then takes a type of bread, completes the sandwich, and serves it up!</p>
<p>So, every time a customer comes, you just have to call your pre-configured <code>makeChickenSandwich</code> or <code>makeVeggieSandwich</code> function with their choice of bread. Each function can be attached to its custom button. Now, you only have to hit the chicken or veggie button without having to worry about what could have been if you had only one sandwich button.</p>
<p><strong>Use-Case #4: left Hook, right Hook, southpaw, useState Hook.</strong><br />This is easily my favorite use case. I have been using the React's <code>useState</code> hook for years. I never cared about its implementation details. still don't.<br />however, you might begin to wonder, perhaps, the <code>useState</code> hook uses closure under the hood.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> React, { useState } <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>;

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Counter</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">const</span> [count, setCount] = useState(<span class="hljs-number">0</span>);

  <span class="hljs-keyword">const</span> increment = <span class="hljs-function">() =&gt;</span> {
    setCount(count + <span class="hljs-number">1</span>);
  };

  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Count: {count}<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{increment}</span>&gt;</span>Increment<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
}
</code></pre>
<p>What is going on here?</p>
<ul>
<li><p><strong>State Preservation</strong>: <code>useState</code> gives you a variable (<code>state</code>) and a function to update it (<code>setState</code>). This state variable is preserved between function calls, much like a closure!</p>
</li>
<li><p><strong>Functional Updates</strong>: This is where closures really kick in. When you update the state based on the previous state, you do something like this:</p>
<pre><code class="lang-javascript">  setCounter(<span class="hljs-function"><span class="hljs-params">prevCounter</span> =&gt;</span> prevCounter + <span class="hljs-number">1</span>);
</code></pre>
<p>  Notice <code>prevCounter</code>? That's the previous state captured and passed into the function. setCounter must be a closure, folks!</p>
</li>
</ul>
<h2 id="heading-closing-prayer"><strong>Closing Prayer</strong></h2>
<p>Understanding closures in JavaScript is crucial for anyone looking to master the language. Closures offer a way to preserve <a target="_blank" href="https://en.wikipedia.org/wiki/State_(computer_science)">state</a>, encapsulate private variables, and enable dynamic function generation. Even if you're not keeping closures in your pocket for everyday use, knowing how they work demystifies a whole bunch of JavaScript quirks. Think of it as being able to see The Matrix. This understanding will prove invaluable across various JavaScript frameworks and libraries.</p>
]]></content:encoded></item><item><title><![CDATA[Busting Myths: Git, the Unsung Hero of DevOps]]></title><description><![CDATA["DevOps engineers don't really need the knowledge of git". That is something you might say to yourself if you are still quite new to programming. after all, isn't DevOps all about infrastructure, deployment, and automation? okay! maybe testing too. w...]]></description><link>https://blog.lekan.dev/busting-myths-git-the-unsung-hero-of-devops</link><guid isPermaLink="true">https://blog.lekan.dev/busting-myths-git-the-unsung-hero-of-devops</guid><category><![CDATA[Devops]]></category><category><![CDATA[Git]]></category><category><![CDATA[version control]]></category><category><![CDATA[Software Engineering]]></category><dc:creator><![CDATA[Olalekan Abdulfatah]]></dc:creator><pubDate>Sun, 23 Jul 2023 18:38:29 GMT</pubDate><content:encoded><![CDATA[<p>"DevOps engineers don't really need the knowledge of git". That is something you might say to yourself if you are still quite new to programming. after all, isn't DevOps all about infrastructure, deployment, and automation? okay! maybe testing too. why would they need to border about the version control system that's typically the domain of developers? Well, if you've been nodding along with this line of thinking, I am here to say - you are mistaken. haha.<br />DevOps engineers absolutely need to know Git. Why, you ask? Well, we will dive into that and uncover the truth about the critical role of Git in the world of DevOps but first, let us see what could have created such thinking to start with.  </p>
<h2 id="heading-the-myth">The Myth</h2>
<p>It's very easy to see where the misconception comes from. When people think of DevOps, they often picture complex deployment pipelines, cloud infrastructure, and automation tools. Git, on the other hand, is usually associated with developers pushing and pulling code, resolving merge conflicts, and managing branches. It's easy to see why some might believe that Git doesn't really factor into the DevOps equation.</p>
<p><a target="_blank" href="https://blog.hubspot.com/hs-fs/hubfs/GettyImages-1288847618.jpg?width=1188&amp;name=GettyImages-1288847618.jpg"><img src="https://blog.hubspot.com/hs-fs/hubfs/GettyImages-1288847618.jpg?width=1188&amp;name=GettyImages-1288847618.jpg" alt="Devops life cycle illustration." class="image--center mx-auto" /></a></p>
<p>This myth is further fueled by the fact that DevOps is often seen as a bridge between the development and operations teams. The focus tends to be on the 'Ops' part of DevOps, with less attention given to the 'Dev' side. As a result, the importance of understanding developer tools like Git can be overlooked. But what is the reality?</p>
<h3 id="heading-the-reality">The Reality</h3>
<p>But here's the thing: DevOps isn't just about managing servers or deploying code. It also involves improving collaboration and efficiency across the entire development lifecycle. And guess what tool is absolutely essential for that? You git it right - Git.</p>
<h3 id="heading-okay-but-why"><strong>Okay. But, why?</strong></h3>
<p>Git is more than just a version control system. It's a tool that enables teams to work together efficiently. It allows multiple developers to work on the same codebase without stepping on each other's toes. It keeps a record of all changes, making it easier to track down bugs and understand the history of your project. It facilitates code reviews and discussions about code changes. In short, Git is a tool that enables the kind of collaboration that DevOps is all about.</p>
<p>Moreover, Git plays a crucial role in Continuous Integration/Continuous Deployment (CI/CD), a key practice in DevOps. CI/CD pipelines often rely on Git repositories to trigger builds and deployments. When a developer pushes code to a Git repository, it can automatically kick off a series of actions like running tests, building the application, and deploying it to a staging or production environment.</p>
<p>we can't forget another powerful feature of Git: rollbacks. If something goes wrong, Git makes it easy to revert to a previous version of your code. This can be a lifesaver when you're dealing with a production issue and need to quickly restore a stable state.</p>
<p>So, while it might seem like Git is just a developer's tool, the reality is that it's a vital part of the DevOps landscape. Understanding Git is not just a 'nice-to-have' for DevOps engineers - it's a must.</p>
<p><strong>Basic Git Commands for DevOps</strong></p>
<p>Haha! This is unfortunately not a git tutorial. We're only here to debunk the supposed myth. Do not be worried though, I might cover Git commands and git workflows in a future article. Stay tuned!</p>
<h3 id="heading-conclusions">Conclusions</h3>
<p>In DevOps, Git is not just a version control system. It's a collaboration tool, an enabler of efficient workflows, and a key player in CI/CD pipelines. It is an unsung hero of devops.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1690137119979/fdd68e7f-9fd9-41c1-96a3-ec1ba57ec78c.jpeg" alt class="image--center mx-auto" /></p>
<p><a target="_blank" href="https://www.freepik.com/free-vector/boy-superhero-costume-full-length-portrait-isolated-white-background-vector-illustration_1158797.htm#query=hero&amp;position=7&amp;from_view=keyword&amp;track=sph">Image by macrovector</a> on Freepik</p>
<p>So, if you've been underestimating the role of Git in DevOps, it's time for a rethink. I can't say Git should be the first skill you pickup on your journey to being a DevOps engineer but, it certainly is a skill you must pick up.</p>
]]></content:encoded></item></channel></rss>