<?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: Selasie Sepenu</title>
    <description>The latest articles on Forem by Selasie Sepenu (@selasie5).</description>
    <link>https://forem.com/selasie5</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%2F1157746%2F63aa25bc-c80d-4a6e-b636-165ff0474841.jpeg</url>
      <title>Forem: Selasie Sepenu</title>
      <link>https://forem.com/selasie5</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/selasie5"/>
    <language>en</language>
    <item>
      <title>How JavaScript Executes Code: Understanding Execution Context and the Call Stack</title>
      <dc:creator>Selasie Sepenu</dc:creator>
      <pubDate>Sun, 11 May 2025 21:54:37 +0000</pubDate>
      <link>https://forem.com/selasie5/how-javascript-executes-code-understanding-execution-context-and-the-call-stack-4aj5</link>
      <guid>https://forem.com/selasie5/how-javascript-executes-code-understanding-execution-context-and-the-call-stack-4aj5</guid>
      <description>&lt;p&gt;JavaScript is a single-threaded, synchronous programming language at its core, but it handles asynchronous operations through clever mechanisms like the event loop. To truly understand how JavaScript works under the hood, you need to grasp two fundamental concepts: &lt;strong&gt;execution context&lt;/strong&gt; and the &lt;strong&gt;call stack&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The JavaScript Execution Context
&lt;/h2&gt;

&lt;p&gt;An execution context is an abstract concept that holds information about the environment where JavaScript code is executed. There are three types of execution contexts in JavaScript:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Global Execution Context&lt;/strong&gt;: Created when the JavaScript engine first starts executing your code&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Function Execution Context&lt;/strong&gt;: Created whenever a function is invoked&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Eval Execution Context&lt;/strong&gt;: Created inside an &lt;code&gt;eval&lt;/code&gt; function (rarely used)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Each execution context has two phases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Creation phase&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Execution phase&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Creation Phase
&lt;/h3&gt;

&lt;p&gt;During the creation phase, the JavaScript engine:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Creates the &lt;strong&gt;Variable Object (VO)&lt;/strong&gt; which contains:

&lt;ul&gt;
&lt;li&gt;Function arguments (for function contexts)&lt;/li&gt;
&lt;li&gt;Inner variable declarations (but not their assignments)&lt;/li&gt;
&lt;li&gt;Function declarations&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Creates the &lt;strong&gt;scope chain&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Determines the value of &lt;code&gt;this&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This explains &lt;strong&gt;hoisting&lt;/strong&gt; - why you can use functions before they're declared in your code, but variables will be &lt;code&gt;undefined&lt;/code&gt; until their actual assignment.&lt;/p&gt;

&lt;h3&gt;
  
  
  Execution Phase
&lt;/h3&gt;

&lt;p&gt;During the execution phase:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The code is executed line by line&lt;/li&gt;
&lt;li&gt;Variables are assigned values&lt;/li&gt;
&lt;li&gt;Functions are executed when called&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Call Stack
&lt;/h2&gt;

&lt;p&gt;The call stack is a data structure that keeps track of function calls in your program. It works on the &lt;strong&gt;LIFO&lt;/strong&gt; principle (Last In, First Out).&lt;/p&gt;

&lt;p&gt;Here's how it works:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;When the JavaScript engine starts executing your script, it creates a global execution context and pushes it onto the call stack&lt;/li&gt;
&lt;li&gt;When a function is called, a new execution context for that function is created and pushed onto the stack&lt;/li&gt;
&lt;li&gt;When a function returns, its execution context is popped off the stack&lt;/li&gt;
&lt;li&gt;The engine continues executing the current context (now the one below in the stack)
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;first&lt;/span&gt;&lt;span class="p"&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="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Inside first function&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;second&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="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Back to first function&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="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;second&lt;/span&gt;&lt;span class="p"&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="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Inside second function&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;third&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="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Back to second function&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="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;third&lt;/span&gt;&lt;span class="p"&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="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Inside third function&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="nf"&gt;first&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="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Global execution&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;The call stack for this code would look like:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;third()&lt;/code&gt; is pushed when called from &lt;code&gt;second()&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;second()&lt;/code&gt; is pushed when called from &lt;code&gt;first()&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;first()&lt;/code&gt; is pushed when called from global&lt;/li&gt;
&lt;li&gt;Global execution context is always at the bottom&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When &lt;code&gt;third()&lt;/code&gt; completes, it's popped off, then &lt;code&gt;second()&lt;/code&gt;, then &lt;code&gt;first()&lt;/code&gt;, and finally the global context remains until the program ends.&lt;/p&gt;

&lt;h2&gt;
  
  
  Visualizing the Process
&lt;/h2&gt;

&lt;p&gt;Let's examine a concrete example:&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;var&lt;/span&gt; &lt;span class="nx"&gt;a&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="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;square&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;num&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;num&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;num&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;result&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;squareOfTwo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;square&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;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;squareOfTwo&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Execution steps:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Global Execution Context Creation&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creates variable object with:

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;a: undefined&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;square: &amp;lt;function&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;squareOfTwo: undefined&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Sets up scope chain&lt;/li&gt;
&lt;li&gt;Determines &lt;code&gt;this&lt;/code&gt; (window in browsers)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Global Execution&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Assigns &lt;code&gt;a = 2&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Reaches &lt;code&gt;square(a)&lt;/code&gt; call:

&lt;ul&gt;
&lt;li&gt;Creates new execution context for &lt;code&gt;square&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Creation phase for &lt;code&gt;square&lt;/code&gt;:&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;num: 2&lt;/code&gt; (from argument)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;result: undefined&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Execution phase for &lt;code&gt;square&lt;/code&gt;:&lt;/li&gt;
&lt;li&gt;Calculates &lt;code&gt;result = 2 * 2&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Returns &lt;code&gt;4&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;square&lt;/code&gt; context is popped from call stack&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Assigns return value to &lt;code&gt;squareOfTwo = 4&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Calls &lt;code&gt;console.log(4)&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;Creates context for &lt;code&gt;console.log&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Executes it&lt;/li&gt;
&lt;li&gt;Pops it from stack&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Program completes, global context is popped&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Handling Asynchronous Code
&lt;/h2&gt;

&lt;p&gt;While the call stack handles synchronous operations, asynchronous operations (like setTimeout, promises, or AJAX calls) are handled by the browser APIs and the event queue. The event loop constantly checks if the call stack is empty, and if so, pushes the next callback from the queue to the stack.&lt;/p&gt;

&lt;p&gt;This separation is why JavaScript can handle asynchronous operations despite being single-threaded.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;JavaScript executes code by creating and managing execution contexts&lt;/li&gt;
&lt;li&gt;Each context has creation and execution phases&lt;/li&gt;
&lt;li&gt;The call stack tracks the execution order of functions&lt;/li&gt;
&lt;li&gt;Understanding these concepts explains hoisting, scope, and closure behaviors&lt;/li&gt;
&lt;li&gt;Asynchronous operations are handled outside the main call stack&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I believe this has been both helpful and insightful to all Javascript developers.Until some other time, happy coding🎉🎉&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How Engineering Saved My Friend’s Blog $15 a Month—And Why It Matters</title>
      <dc:creator>Selasie Sepenu</dc:creator>
      <pubDate>Sun, 16 Mar 2025 23:48:58 +0000</pubDate>
      <link>https://forem.com/selasie5/how-engineering-saved-my-friends-blog-15-a-month-and-why-it-matters-2lma</link>
      <guid>https://forem.com/selasie5/how-engineering-saved-my-friends-blog-15-a-month-and-why-it-matters-2lma</guid>
      <description>&lt;p&gt;In the world of software development, there’s a saying: &lt;em&gt;“Why buy when you can build?”&lt;/em&gt; While this isn’t always the best advice (sometimes reinventing the wheel is a waste of time), there are moments when rolling up your sleeves and building a custom solution can lead to significant savings, better control, and a deeper understanding of your system. This is the story of how I helped my friend save $15 a month by engineering a feature for their blog—and why it’s a win worth celebrating.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;The Problem: Real-Time Comments on a Budget&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Having built out the basic functionality for my friend's blog, she wanted to include a comments section where readers could engage with their content. Since we had already used &lt;strong&gt;Sanity.io&lt;/strong&gt; to this point, we initially considered using it again for this feature. However, Sanity offers a real-time comments feature, but it comes at a cost: &lt;strong&gt;$15 per month&lt;/strong&gt;. While $15 might not seem like much, over time, it adds up. For a small blog, every dollar counts, and we wanted to avoid recurring costs wherever possible.&lt;/p&gt;

&lt;p&gt;But the real question was: &lt;em&gt;Could we build this feature ourselves?&lt;/em&gt; And if so, would it be worth the effort?&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;The Solution: Building a Custom Real-Time Comments System&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Instead of paying for Sanity’s real-time comments feature, I decided to engineer a custom solution using &lt;strong&gt;Supabase&lt;/strong&gt;, an open-source alternative to Firebase. Here’s how I did it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Database Setup&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I created a &lt;code&gt;comments&lt;/code&gt; table in Supabase to store all comments. Each comment included fields like &lt;code&gt;name&lt;/code&gt;, &lt;code&gt;email&lt;/code&gt;, &lt;code&gt;comment&lt;/code&gt;, &lt;code&gt;post_id&lt;/code&gt;, and &lt;code&gt;created_at&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Real-Time Updates&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Supabase’s real-time functionality allowed me to listen for new comments and update the UI dynamically. This meant readers could see new comments appear instantly without refreshing the page.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Custom API&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I built a simple API endpoint to handle comment submissions. When a reader submits a comment, it’s saved to the Supabase database, and the real-time subscription updates the UI.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Cost Savings&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Supabase’s free tier was more than enough for our needs, meaning we paid &lt;strong&gt;$0&lt;/strong&gt; for this feature. Over time, this saves my friend &lt;strong&gt;$180 per year&lt;/strong&gt;—and potentially thousands over the lifetime of the blog.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;The Engineering Advantage&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Building this feature wasn’t just about saving money. It was about &lt;strong&gt;flexibility&lt;/strong&gt;, &lt;strong&gt;control&lt;/strong&gt;, and &lt;strong&gt;learning&lt;/strong&gt;. Here’s why engineering this solution was worth it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Total Control&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;By building the feature ourselves, we had complete control over how it worked. We could customize the UI, add new features (like comment moderation), and optimize performance.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;No Vendor Lock-In&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Relying on a third-party service like Sanity’s real-time comments feature would have tied us to their platform. By using Supabase, we retained the freedom to switch databases or even build our own backend in the future.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Learning Opportunity&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Building this feature from scratch gave me a deeper understanding of real-time systems, database design, and API integration. These skills are invaluable and can be applied to future projects.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Cost Efficiency&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;While $15 a month might seem trivial, it’s a recurring cost that adds up over time. By building the feature ourselves, we saved &lt;strong&gt;$180 per year&lt;/strong&gt;—money that can now be invested in other areas of the blog.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;The Bigger Picture: Why This Matters&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;This isn’t just a story about saving $15 a month. It’s a story about &lt;strong&gt;empowerment through engineering&lt;/strong&gt;. In a world where SaaS solutions are often the default choice, it’s easy to forget the value of building things yourself. Here’s why this approach matters:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Sustainability&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Recurring costs can quickly add up, especially for small projects or startups. By building custom solutions, we can keep expenses low and reinvest savings into growth.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Customization&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Off-the-shelf solutions often come with limitations. Building our own feature allows us to tailor it to our exact needs.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Skill Development&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Every project is an opportunity to learn. By building this feature, I gained valuable experience that will benefit me in future endeavors.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Independence&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Relying on third-party services can be risky. By building our own solutions, we reduce dependency on external providers and gain more control over our product.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;The Takeaway: Build vs. Buy&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;So, should we always build instead of buy? Not necessarily. There are times when using a third-party service makes sense—especially when time is limited or the feature is highly complex. But for small, manageable features like a comments section, building our own solution can be a smart move.&lt;/p&gt;

&lt;p&gt;In this case, engineering the real-time comments feature saved my friend $15 a month, but more importantly, it gave us &lt;strong&gt;control&lt;/strong&gt;, &lt;strong&gt;flexibility&lt;/strong&gt;, and &lt;strong&gt;confidence&lt;/strong&gt; in our ability to solve problems. And that’s worth far more than $15.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Final Thoughts&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In the end, this project was a reminder that &lt;strong&gt;engineering is about more than just writing code&lt;/strong&gt;. It’s about solving problems, making smart decisions, and creating value. By building our own real-time comments system, we not only saved money but also gained a deeper appreciation for the power of engineering.&lt;/p&gt;

&lt;p&gt;So, the next time we’re faced with a decision to build or buy, we’ll ask ourselves: &lt;em&gt;Can we engineer a solution that’s better, cheaper, and more aligned with our goals?&lt;/em&gt; If the answer is yes, we’ll roll up our sleeves and start building. The rewards—both financial and personal—are well worth it.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;What do you think?&lt;/strong&gt; Have you ever built a custom solution to save money or gain more control? Share your story in the comments below! (And yes, the comments are real-time, thanks to our custom-built system. 😉)&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Hey everyone. Please do well to check out my latest post.</title>
      <dc:creator>Selasie Sepenu</dc:creator>
      <pubDate>Tue, 11 Mar 2025 14:15:45 +0000</pubDate>
      <link>https://forem.com/selasie5/hey-everyone-please-do-well-to-check-out-my-latest-post-2fgn</link>
      <guid>https://forem.com/selasie5/hey-everyone-please-do-well-to-check-out-my-latest-post-2fgn</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/selasie5" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1157746%2F63aa25bc-c80d-4a6e-b636-165ff0474841.jpeg" alt="selasie5"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/selasie5/building-a-global-modal-system-in-nextjs-a-deep-dive-into-client-side-state-management-nbl" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Building a Global Modal System in Next.js: A Deep Dive into Client-Side State Management&lt;/h2&gt;
      &lt;h3&gt;Selasie Sepenu ・ Mar 11&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#programming&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#webdev&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#typescript&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#nextjs&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>programming</category>
      <category>webdev</category>
      <category>typescript</category>
      <category>nextjs</category>
    </item>
    <item>
      <title>Building a Global Modal System in Next.js: A Deep Dive into Client-Side State Management</title>
      <dc:creator>Selasie Sepenu</dc:creator>
      <pubDate>Tue, 11 Mar 2025 14:14:54 +0000</pubDate>
      <link>https://forem.com/selasie5/building-a-global-modal-system-in-nextjs-a-deep-dive-into-client-side-state-management-nbl</link>
      <guid>https://forem.com/selasie5/building-a-global-modal-system-in-nextjs-a-deep-dive-into-client-side-state-management-nbl</guid>
      <description>&lt;p&gt;Creating a seamless and reusable modal system is a common requirement in modern web development. Modals are used for everything from user authentication to notifications, and they need to be accessible, performant, and easy to manage across an application. However, implementing a global modal system in a framework like Next.js—especially with the introduction of Server Components—can be tricky. In this article, I’ll walk you through my experience building a global modal system using Zustand for state management, React Portals for rendering, and the challenges I faced along the way.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;The Problem: A Global Modal System&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The goal was simple: create a modal that could be triggered from anywhere in the application and would render consistently across all pages. The modal needed to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Be Global&lt;/strong&gt;: Accessible from any component or page.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Be Performant&lt;/strong&gt;: Avoid unnecessary re-renders.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Work with Server Components&lt;/strong&gt;: Next.js 13+ utilizes Server Components, which complicated things because React hooks (like Zustand’s &lt;code&gt;useStore&lt;/code&gt;) can only be used in Client Components.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;At first glance, this seemed straightforward. However, as I dove deeper, I encountered several challenges that required creative solutions.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;The Initial Approach: Wrapping the Application&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;My first thought was to wrap the entire application in a &lt;code&gt;ClientWrapper&lt;/code&gt; component that would handle the modal logic. This wrapper would use Zustand to manage the modal’s state and conditionally render the modal based on that state.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;The Code&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Here’s what the initial implementation looked like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;use client&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useModalStore&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@/store/store&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;WaitlistModal&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@/components/ui/Modal&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ReactNode&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;ClientWrapperProps&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;children&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ReactNode&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;ClientWrapper&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;children&lt;/span&gt; &lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="nx"&gt;ClientWrapperProps&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="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;isModalOpen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;closeModal&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useModalStore&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;WaitlistModal&lt;/span&gt; &lt;span class="nx"&gt;isOpen&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;isModalOpen&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;onClose&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;closeModal&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;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;h3&gt;
  
  
  &lt;strong&gt;The Problem&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;While this approach worked in theory, it introduced a critical issue: &lt;strong&gt;unreachable code&lt;/strong&gt;. When the &lt;code&gt;children&lt;/code&gt; were rendered first, the &lt;code&gt;WaitlistModal&lt;/code&gt; became unreachable, and vice versa. This was due to the way React handles component rendering and the order of operations.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;The Solution: React Portals&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To solve the unreachable code issue, I turned to &lt;strong&gt;React Portals&lt;/strong&gt;. Portals allow you to render a component outside its parent DOM hierarchy, which is perfect for modals that need to appear above all other content.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;What Are Portals?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Portals are a feature in React that let you render a component into a DOM node outside its parent component. This is particularly useful for modals, tooltips, and other overlay components that need to break out of their container.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Implementing Portals&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;I created a &lt;code&gt;Portal&lt;/code&gt; component to handle the rendering logic:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;use client&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;createPortal&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react-dom&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;PortalProps&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;children&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ReactNode&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Portal&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;children&lt;/span&gt; &lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="nx"&gt;PortalProps&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="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;mounted&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setMounted&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="nf"&gt;useEffect&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="nf"&gt;setMounted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setMounted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&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="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;mounted&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;createPortal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;document&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Updating the Modal Component&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Next, I wrapped the &lt;code&gt;WaitlistModal&lt;/code&gt; component with the &lt;code&gt;Portal&lt;/code&gt; component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;use client&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;motion&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;framer-motion&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Portal&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./Portal&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;WaitlistModalProps&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;isOpen&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;onClose&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="k"&gt;void&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;WaitlistModal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;isOpen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;onClose&lt;/span&gt; &lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="nx"&gt;WaitlistModalProps&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;isOpen&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Portal&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;
        &lt;span class="nx"&gt;initial&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="na"&gt;opacity&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="nx"&gt;animate&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="na"&gt;opacity&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="nx"&gt;exit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="na"&gt;opacity&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="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fixed inset-0 bg-black bg-opacity-50 flex justify-center items-center z-50&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
        &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;onClose&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;
          &lt;span class="nx"&gt;initial&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="na"&gt;y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;opacity&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="nx"&gt;animate&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="na"&gt;y&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="na"&gt;opacity&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="nx"&gt;exit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="na"&gt;y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;opacity&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="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bg-white rounded-lg p-8 w-full max-w-md relative z-60&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
          &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stopPropagation&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="cm"&gt;/* Modal content */&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/motion.div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/motion.div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Portal&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;WaitlistModal&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Why Portals Work&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Portals solved the unreachable code issue by rendering the modal outside the main component tree. This ensured that the modal would always appear above other content, regardless of where it was triggered.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;The Next Challenge: Server Components&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;With the modal working as expected, I encountered a new challenge: &lt;strong&gt;Server Components&lt;/strong&gt;. Next.js 13+ utilizes Server Components, which are rendered on the server and cannot use React hooks like &lt;code&gt;useState&lt;/code&gt; or &lt;code&gt;useStore&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;The Error&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;When I tried to use &lt;code&gt;useModalStore&lt;/code&gt; in the &lt;code&gt;app/layout.tsx&lt;/code&gt; file, I got the following error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Error: useSyncExternalStore only works in Client Components. Add the "use client" directive at the top of the file to use it.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;The Solution: A Modal Provider&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;To resolve this, I created a &lt;code&gt;ModalProvider&lt;/code&gt; component that would handle the modal logic and render the &lt;code&gt;WaitlistModal&lt;/code&gt;. This component would be a &lt;strong&gt;Client Component&lt;/strong&gt;, ensuring that &lt;code&gt;useModalStore&lt;/code&gt; could be used without issues.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;ModalProvider.tsx&lt;/strong&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;use client&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useModalStore&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@/store/store&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;WaitlistModal&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@/components/ui/Modal&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;ModalProvider&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="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;isModalOpen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;closeModal&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useModalStore&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;WaitlistModal&lt;/span&gt; &lt;span class="nx"&gt;isOpen&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;isModalOpen&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;onClose&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;closeModal&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;strong&gt;Updating the Layout&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;I then included the &lt;code&gt;ModalProvider&lt;/code&gt; in the &lt;code&gt;app/layout.tsx&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Inter&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;next/font/google&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./globals.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;ModalProvider&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@/components/ModalProvider&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;inter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Inter&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;subsets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;latin&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="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;RootLayout&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;children&lt;/span&gt; &lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;children&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ReactNode&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="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt; &lt;span class="nx"&gt;lang&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;en&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;inter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;className&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;children&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ModalProvider&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/body&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html&lt;/span&gt;&lt;span class="err"&gt;&amp;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;h2&gt;
  
  
  &lt;strong&gt;The Final Result&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;With these changes, the global modal system was fully functional:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Global Access&lt;/strong&gt;: The modal could be triggered from any component using the &lt;code&gt;useModalStore&lt;/code&gt; hook.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Performant&lt;/strong&gt;: The modal was rendered only when needed, avoiding unnecessary re-renders.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Server-Safe&lt;/strong&gt;: The modal logic was handled in a Client Component, ensuring compatibility with Server Components.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Key Takeaways&lt;/strong&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Portals Are Powerful&lt;/strong&gt;: React Portals are an excellent tool for rendering components outside their parent hierarchy, making them ideal for modals and overlays.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Separate Client and Server Logic&lt;/strong&gt;: When working with Next.js Server Components, it’s essential to separate client-side logic into dedicated Client Components.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;State Management Matters&lt;/strong&gt;: Zustand provided a simple and effective way to manage global state, but it’s crucial to use it correctly in a Server Components architecture.&lt;/li&gt;
&lt;/ol&gt;




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

&lt;p&gt;Building a global modal system in Next.js was a challenging but rewarding experience. By leveraging React Portals, Zustand, and a clear separation of client and server logic, I was able to create a performant and reusable solution. If you’re working on a similar project, I hope this article provides valuable insights and helps you avoid common pitfalls.&lt;/p&gt;

&lt;p&gt;Happy coding! 🚀&lt;/p&gt;

</description>
      <category>programming</category>
      <category>webdev</category>
      <category>typescript</category>
      <category>nextjs</category>
    </item>
    <item>
      <title>Demystifying Big O Notation: A Guide For Software Engineers</title>
      <dc:creator>Selasie Sepenu</dc:creator>
      <pubDate>Fri, 26 Jul 2024 15:21:08 +0000</pubDate>
      <link>https://forem.com/selasie5/demystifying-big-o-notation-a-guide-for-software-engineers-3f9l</link>
      <guid>https://forem.com/selasie5/demystifying-big-o-notation-a-guide-for-software-engineers-3f9l</guid>
      <description>&lt;p&gt;As engineers,we constantly strive to write efficient code.But how do we measure and communicate efficiency in our algorithms? This is where the Big O notation comes in. Big O notation is a mathematical concept used to describe the performance of an algorithm in terms of time and space complexity. In this article, we will break down Big O notation, make it accessible and understandable for engineers of all levels.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What is Big O Notation?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Big O notation provides a high-level understanding of the efficiency of an algorithm. It describes the upper bound of the algorithms running time or space requirement in the worstcase scenario. This allows us to compare different algorithms and determine which one is more efficient as the input size grows.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Why is Big O notation important?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Understanding Big O notation crucial for several reasons:&lt;br&gt;
&lt;strong&gt;1)Performance Optimization&lt;/strong&gt;: It allows developers to choose the most efficient algorithm for a given problem.&lt;br&gt;
&lt;strong&gt;2)Scalability&lt;/strong&gt;: It ensures that the chosen algorithm can handle larger inputs without degrading performance significantly.&lt;br&gt;
&lt;strong&gt;3)Algorithm Comparison:&lt;/strong&gt; It allows developers to choose the most efficient algorithm for a given problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Common Big O Notations&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;O(1)-Constant Time: The algorithms performance remains constant, regardless of input size. &lt;br&gt;
Example: Accessing an array by index.&lt;/p&gt;

&lt;p&gt;O(logn): The algorithm's performance increases logarithmically with the input size. &lt;br&gt;
Example: Binary Search&lt;/p&gt;

&lt;p&gt;O(n)-Linear Time: The algorithm's performance increases linearlty with input size.&lt;br&gt;
Example: Iterating through an array.&lt;/p&gt;

&lt;p&gt;O(nlogn)-Linearithmic Time: The algorithms performance increases linearly and logarithmically with the input size.&lt;br&gt;
Example: Merge Sort&lt;/p&gt;

&lt;p&gt;O(n^2)-Quadratic Time: The algorithm's performance increases quadratically with input size.&lt;br&gt;
Exmaple: Bubble Sort&lt;/p&gt;

&lt;p&gt;0(2^n) - Exponential Time:  The algortithm's performance doubles with each addtional input.&lt;br&gt;
Example: Recursive Fibonacci Calculation&lt;/p&gt;

&lt;p&gt;0(n!) -Factorial Time: The algorithm's performance increases with the input size. &lt;br&gt;
Example: Solving the travelling salesman problem using brute force.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F85s8t49jjk4edz74u5jt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F85s8t49jjk4edz74u5jt.png" alt="Image description" width="650" height="408"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Big O notation is an essential tool for engineers to evaluate and optimize the efficiency of their algorithms.By understanding types of Big O notations and their implications, you can write more efficient code and make the better algorithmic choices. In the next article, we'll dive deeper into pratical examples and explore the how to analyze the Big O notation of real-world examples.&lt;/p&gt;

</description>
      <category>softwareengineering</category>
      <category>data</category>
      <category>algorithms</category>
      <category>development</category>
    </item>
  </channel>
</rss>
