<?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>DEV Community: Pierre Mouchan</title>
    <description>The latest articles on DEV Community by Pierre Mouchan (@pierremouchan).</description>
    <link>https://dev.to/pierremouchan</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%2F170651%2Fdd00dabc-083e-4103-8314-5cdb8c565d2a.png</url>
      <title>DEV Community: Pierre Mouchan</title>
      <link>https://dev.to/pierremouchan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pierremouchan"/>
    <language>en</language>
    <item>
      <title>How I created a live subscribers counter in NextJS (with source code)</title>
      <dc:creator>Pierre Mouchan</dc:creator>
      <pubDate>Tue, 11 Jun 2024 12:53:00 +0000</pubDate>
      <link>https://dev.to/pierremouchan/how-i-created-a-live-subscribers-counter-with-peoples-avatars-in-nextjs-with-source-code-1l07</link>
      <guid>https://dev.to/pierremouchan/how-i-created-a-live-subscribers-counter-with-peoples-avatars-in-nextjs-with-source-code-1l07</guid>
      <description>&lt;h1&gt;
  
  
  How I Created a Live Subscribers Counter in NextJS
&lt;/h1&gt;

&lt;p&gt;Hey web developers,&lt;br&gt;
I built an engaging feature on a newsletter subscription page to enhance the user experience and trust of my &lt;a href="https://www.obsibrain.com"&gt;Obsibrain&lt;/a&gt; landing page. One intriguing way of doing this is by displaying a live subscriber counter. In this article, I will walk you through how I created such a feature using Next.js API and the Brevo API.&lt;/p&gt;
&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In this tutorial, we will build a function that fetches the number of subscribers from Brevo and displays the total number on the front-end. Whenever there is a new subscriber, the counter will be updated in real-time.&lt;/p&gt;
&lt;h2&gt;
  
  
  First things first, the basic Next.js API route
&lt;/h2&gt;

&lt;p&gt;This is the foundation of a Next.js API route. &lt;br&gt;
The &lt;code&gt;GET&lt;/code&gt; function is an asynchronous function that serves as the request handler for HTTP GET requests to this API endpoint.&lt;/p&gt;

&lt;p&gt;This API route is located under:&lt;br&gt;
&lt;code&gt;app &amp;gt; api &amp;gt; get-subscriptions &amp;gt; route.ts&lt;/code&gt;&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="kd"&gt;type&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;NextRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;NextResponse&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="s1"&gt;next/server&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;NextRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;NextResponse&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// More code...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Getting the Subscribers from Brevo
&lt;/h2&gt;

&lt;p&gt;First things first, let's fetch the list of subscribers. We use the Brevo API for this purpose. &lt;br&gt;
(explanation inside the code snippet)&lt;/p&gt;

&lt;p&gt;Here's the code snippet:&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="nx"&gt;dotenv&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dotenv&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;NextRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;NextResponse&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="s1"&gt;next/server&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="nx"&gt;dotenv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;config&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;BASE_URL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`https://api.brevo.com/v3`&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;API_KEY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;BREVO_API_KEY&lt;/span&gt;

&lt;span class="c1"&gt;// full url&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;BASE_URL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;contacts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/&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;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;NextRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;NextResponse&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// making the request with the required headers&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;GET&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;headers&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="s1"&gt;Accept&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;application/json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;api-key&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;API_KEY&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;})&lt;/span&gt;

      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c1"&gt;// checking for the response to be 'ok' and be successful&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;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ok&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="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Error getting list of subscriptions&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="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;500&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;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&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="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Error getting list of subscriptions&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="p"&gt;}),&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;500&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Invalidating on Each New Subscriber
&lt;/h2&gt;

&lt;p&gt;To keep our subscriber list fresh and updated, we use the revalidation option provided by Next.js to invalidate the cached data and fetch fresh data periodically both on backend and frontend.&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;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;revalidate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;NextRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;NextResponse&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="c1"&gt;//...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By setting &lt;code&gt;revalidate&lt;/code&gt; to 300 seconds, the data will be revalidated every 5 minutes (backend) to ensure we are displaying the most current subscriber count.&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;GET&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;headers&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="s1"&gt;Accept&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;application/json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;api-key&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;API_KEY&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="na"&gt;next&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;tags&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="s1"&gt;subscriptions&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="c1"&gt;// NextJS tags&lt;/span&gt;

      &lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;tags&lt;/code&gt; property is an array of strings that can be used to uniquely identify a request. This is particularly useful when you want to invalidate the cache for a specific request in the future.&lt;/p&gt;

&lt;p&gt;This means that whenever the cache for this specific request needs to be invalidated (for example, when a new subscriber is added), Next.js can target this request by looking for the &lt;code&gt;'subscriptions'&lt;/code&gt; tag (used in frontend in our case but can be invalidated on backend as well).&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;revalidateTag&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="s1"&gt;next/cache&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="nf"&gt;revalidateTag&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;subscriptions&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// revalidate the cache for the get-subscriptions route&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Returning the Data
&lt;/h2&gt;

&lt;p&gt;Once we've fetched the subscriber data, the final step is to return this information in a structured format. The function wraps up the data in a JSON response that includes the total number of subscribers.&lt;/p&gt;

&lt;p&gt;Here's the concluding part of the code:&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;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Subscriptions fetched successfully&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;totalSubscriptions&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="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This structured response allows the front-end to easily consume the data and dynamically update the subscriber count, ensuring a live, optimized (with cache) and interactive user experience.&lt;/p&gt;

&lt;h2&gt;
  
  
  Any Questions?
&lt;/h2&gt;

&lt;p&gt;If you have any questions about my setup or if you encounter any issues while implementing this feature, feel free to reach out. I'm more than happy to provide additional explanations, give advice, or help troubleshoot any problems you might run into.&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>api</category>
      <category>showdev</category>
    </item>
    <item>
      <title>Here Are The Top 3 Reasons I’ve Created A Product To Empower Developers to Build Better Websites</title>
      <dc:creator>Pierre Mouchan</dc:creator>
      <pubDate>Wed, 23 Mar 2022 08:44:41 +0000</pubDate>
      <link>https://dev.to/pierremouchan/here-are-the-top-3-reasons-ive-created-a-product-to-empower-developers-to-build-better-websites-1i12</link>
      <guid>https://dev.to/pierremouchan/here-are-the-top-3-reasons-ive-created-a-product-to-empower-developers-to-build-better-websites-1i12</guid>
      <description>&lt;p&gt;Today, we are living in the digital era of infinite possibilities — Despite their origins, age, and status, people from all over the world are creating different businesses: E-Commerce, tech startup, NFTs, physical goods, etc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Every one of those businesses needs a website.&lt;br&gt;
Every one of those entrepreneurs will try to reach and find a developer.&lt;br&gt;
Every one of those developers will do the job.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But not every developer will do it &lt;em&gt;CORRECTLY&lt;/em&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Today, through my product and this blog article, I am sharing with you what those past 5 years in the industry have led me to think about my job and my colleagues’ work on the internet.&lt;/p&gt;




&lt;h2&gt;
  
  
  I. Seeing too many unoptimized websites.
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fef193nahd9f90ijevmmc.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fef193nahd9f90ijevmmc.jpeg" alt="Bad performances impacting the overall SEO." width="742" height="330"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We all see a huge amount of websites that takes ages to load.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You’ll tell me that this is not a problem and that bandwidth will be upgraded in the next following years and that 5G+ will solve all those issues. No more optimizations to do, everything is INSTANT.&lt;/p&gt;

&lt;p&gt;Unfortunately, we haven’t reached this point yet — knowing that in my natal country, I am running on E with my mobile connection (Yep, it really sucks.).&lt;/p&gt;

&lt;p&gt;The answer isn’t to wait for a magic 6G deployment over the whole globe. We all have to optimize our websites and projects at some point.&lt;/p&gt;

&lt;p&gt;It isn’t something easy at first, but with some theory and practice, knowing that the major problems are coming from the size of your images and the libraries that we are using is a big step towards the optimization part.&lt;/p&gt;

&lt;p&gt;We often heard a lot about accessibility and this is a fully different and legitimate topic but websites performance is often never taught in classes and online courses.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;It should.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Loading time isn’t just a matter of performance — it has a huge impact on a site’s success, too.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Amazon found that every 100ms of latency cost them 1% in sales&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Research shows that 53% of mobile users abandon sites that take over 3 seconds to load&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;70% of consumers admit that page speed impacts their willingness to buy from an online retailer&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  II. Seeing too many developers diving into big frameworks without having the fundamentals.
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Getting rich quick-schemes doesn’t exist. Winning $15,000/month without kicking your own b*tt for years doesn’t exist as well.&lt;br&gt;
&lt;strong&gt;I will tell you a secret: it is the same for frameworks.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I’ve seen too many developers diving into React, VueJS, and Angular without any proper fundamentals with JavaScript. Going from HTML basics to React in a few months of practice isn’t the answer.&lt;/p&gt;

&lt;p&gt;I met some guys who were trying to handle some React projects without the basics of Javascript. I think you should at least have 2 years of experience in those basics languages before diving into such a thing. (personal opinion)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It’s like throwing yourself in the middle of a lake and asking you to come back to the shore — The problem is: you don’t know how to swim.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5c44z3u5vnaa8p2d72p1.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5c44z3u5vnaa8p2d72p1.jpeg" alt="Photo by Garrettsears" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do things slowly&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Yeah, I know. It’s frustrating.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You want that job that requires some React skills.&lt;br&gt;
You want to be better than your old colleague who is making awesome websites.&lt;br&gt;
You want to leave your job and become the next Steve Jobs of websites.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;It takes time.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Start with the basics, follow some DEV roadmap online: &lt;a href="https://coggle.it/diagram/XfeRbWj7xy3dsEX8/t/web-development-in-2020"&gt;here is one&lt;/a&gt;, and, with some practices and real experiences, come back and learn React–in this order.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you find yourself in these words, read them several times and follow my advice.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  III. Seeing too many developers working with the wrong mindset and a bad workflow.
&lt;/h2&gt;

&lt;p&gt;If you’ve been working as a developer for some years now, you’ll know that working on someone else project can be a pain in the ***.&lt;/p&gt;

&lt;p&gt;You don’t fully understand his code/choices — you are not inside the other developer’s mind.&lt;/p&gt;

&lt;p&gt;You take ages installing it on your computer — because he/she is using different packages, a different database, and some other mystical and strange software.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ANNNND… You’re telling yourself:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;“Omg, why did he write that? This is not how it should be.”&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;“I am pressing SAVE and nothing is being reformated? wtf.”&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;“This project is a complete mess. Nothing is at the right place.”&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;“What is this horrible thing: const MyNeWVariAbles = 56*4;”&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;“Should I take an axe and threat my boss until he gave me something else to work on?”&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fubp77ddwd00ad9wz013i.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fubp77ddwd00ad9wz013i.jpeg" alt="Photo by Elisa Ventur on Unsplash" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I mean, there is hundreds of thousands of different packages, libraries, and ways to code, its not something that we can easily avoid? Right?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Indeed.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;BUT&lt;/strong&gt;, it is not an excuse to not order your files and folder correctly. It is not an excuse to avoid commenting your code and it is not a reason to &lt;strong&gt;disrespect your own code and work.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;YOUR workflow, EVERYONE’s workflow matters.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  M-I-N-S-E-T
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Sorry, it is not a magical formula that will write some code for you.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;It takes years of practice and self-reflection to become a better developer, to be fully responsible towards our own code, and to handle beautiful projects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We are all improving at our own pace.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A developer with 1 year of experience can actually be smarter and better than another one with 8+ years in the industry–it is &lt;strong&gt;only a question of mindset.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here is a non-exhaustive list of things that comes to me when I am thinking about &lt;strong&gt;“Having the right mindset” and “How a beginner developer can actually beat the senior one”:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Looking for new ways to improve&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Learning how to write better code&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Learning design fundamentals as a developer&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Understanding what REALLY matters when handling website performances&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Stop loading 15 libraries and packages to just use 4 of them&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Stop spending 95% of the project development on the UI part rather than the UX part&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Stop thinking about our own dev comfort zone and business before our clients’ and users’ needs&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;etc.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Today, I hope you fully understand why I wanted to share my knowledge through this product.
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;A quick article and introduction to what is currently working for me.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The workflow and mindset that helps me save time and do more.&lt;/p&gt;

&lt;p&gt;The “behind the scene” concepts that are actually pushing my projects forwards and helping me win some awards.&lt;/p&gt;

&lt;p&gt;And, above all, the best practices that lead me to publish wonderful experiences with incredible SEO and performance optimization.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This guy sums it up better than I do:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“More is less.”&lt;br&gt;
— Ludwig Mies van der Rohe&lt;/p&gt;
&lt;/blockquote&gt;




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

&lt;p&gt;This post isn’t meant to be a ‘self-promotion article’ but if you still want to take a look at all those subjects — Here’s the link to this tool that hopefully will help you in your journey: &lt;a href="https://www.staticstarter.com"&gt;https://www.staticstarter.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you enjoyed this one, take a look at &lt;a href="https://www.getrevue.co/profile/pierremouchan"&gt;my newsletter&lt;/a&gt; — Get my monthly free best resources for developers and designers right into your inbox! 📨&lt;br&gt;
Or simply join the community and follow me on &lt;a href="https://twitter.com/_pierremouchan"&gt;Twitter&lt;/a&gt; 🐦&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>productivity</category>
      <category>product</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Delivering a good Experience as a Developer</title>
      <dc:creator>Pierre Mouchan</dc:creator>
      <pubDate>Thu, 10 Sep 2020 07:56:26 +0000</pubDate>
      <link>https://dev.to/pierremouchan/delivering-a-good-experience-as-a-developer-180</link>
      <guid>https://dev.to/pierremouchan/delivering-a-good-experience-as-a-developer-180</guid>
      <description>&lt;p&gt;&lt;em&gt;Quick note: This is my first article, aiming to warn new developers in the industry and giving a small refresh to all developers! I wrote this one using my experience and some other sources that I will link at the end. Enjoy reading!&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“No product is an island. A product is more than the product. It is a cohesive, integrated set of experiences. Think through all of the stages of a product or service—from initial intentions through final reflections, from first usage to help, service, and maintenance. Make them all work together seamlessly.”&lt;br&gt;
— Donald Norman&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;"Make them all work together seamlessly"&lt;/em&gt;&lt;/strong&gt;, said Donald Norman inventor of the term &lt;strong&gt;“User Experience”&lt;/strong&gt; and professor in cognitive science in the ’90s at the University of California in San Diego. We should know, as developers of any kind, that our mission is to deliver a decent user experience. No matter what (and we will talk later of this “no matter what” again), we have to deliver something solid, something fast and something that can be easily understood and used. This is primarily the job of UX Designer to ensure that our app/website got a good UX but we, as developers, are also responsible for it and we need to make sure it works well.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F2oa65m05xw2ryjd8y63h.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F2oa65m05xw2ryjd8y63h.jpg" alt="Example of bad UX implementation." width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  User Experience (UX) and Developer Experience (DX)
&lt;/h2&gt;

&lt;p&gt;Okay, okay slow down… Let’s defines both of them before diving into the real subject. We often hear about user experience and we should all be aware of this term.&lt;/p&gt;

&lt;h3&gt;
  
  
  User Experience
&lt;/h3&gt;

&lt;p&gt;User Experience (UX) is really hard to explain… Simply because it means A LOT, and regroup A LOT of things. &lt;strong&gt;User Experience is a middle between “User Interface Design” and “Usability”. UX design, like I said cover a vast array of areas. UX design is a long, long process than even begins before the app is in the user’s hand.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Developer Experience
&lt;/h3&gt;

&lt;p&gt;Developer Experience (DX) is quite a new term in the industry. It is greatly related to UX in a sense, and clearly self-explanatory — &lt;strong&gt;"The experience lived by developers.” On the other hand, DX is related to some services especially made FOR developers (the targeted audience).&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s take &lt;a href="https://stripe.com/en-fr"&gt;Stripe&lt;/a&gt; for example (an online payment platform), its usability is quite interesting. How can you know that this service respond to a &lt;strong&gt;DX and not an UX?&lt;/strong&gt; So … you create an account, you log in, you go on the dashboard and BOOM, WOO, Stripe gives you a secret token, Webhooks, a DEVELOPER TAB in the navigation and an API Key?&lt;/p&gt;

&lt;p&gt;An API what?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stripe gives you directly “developers-only” information and doesn’t hide these options and settings in a subdomain like api.stripe.com.&lt;/strong&gt; It’s why a “non-developer” person will be scared by this weird information and will be less tempted to use this online payment service, while a developer would be in paradise.&lt;/p&gt;

&lt;p&gt;A good counterexample is &lt;a href="https://mailchimp.com/"&gt;Mailchimp&lt;/a&gt; (a marketing platform used to manage mailing list, newsletters and campaigns.) &lt;strong&gt;Unlike Stripe, Mailchimp hides the “developers-only” information in a different page.&lt;/strong&gt; Mailchimp isn’t MADE FOR developers (even if developers can use it easily), their main target audience is marketers, which will not have trouble using it and will not be scared by weird developers stuff.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Have you already seen a random guy using Codepen or AWS? Seriously? Hope you understand the difference now. :)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fbkhvax1n95iqpkb97l41.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fbkhvax1n95iqpkb97l41.jpg" alt="Mailchimp and Mailchimp developer differentiation." width="800" height="445"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Internal Developer Experience?
&lt;/h2&gt;

&lt;p&gt;In the previous section, we define the experience that our products as developers should provide. These experiences remains, in a way, totally external, &lt;strong&gt;we provide an experience (UX or DX) for a specific external target.&lt;/strong&gt; We should not forget that we are using the product too (yes, really!) We are touching the internal code of these future applications, so we are using them also, it is logical, right? For me, it’s a complete different branch of the experience that I like to call the &lt;strong&gt;Internal Developer Experience&lt;/strong&gt;. They may sound complicated to understand by now, so l will take an example.&lt;/p&gt;

&lt;h3&gt;
  
  
  John to the Rescue
&lt;/h3&gt;

&lt;p&gt;John is graduated from a marketing school, he was always a smart person and, as the tech industry arise, think that he should learn how to code. So he spent like 5 months taking courses over and over about HTML CSS and JS stuff to get his first job at “Lorem ipsum Agency” as a Front-End Developer. &lt;strong&gt;John never worked in a team before&lt;/strong&gt;, he was just taking these courses online on “How to build a TO-DO list in HTML” &lt;em&gt;(Please stop building to-do list guys, please…)&lt;/em&gt;. John’s first mission was to build a website for a future industry with a navigation bar, a video player and a gallery. No problem for John, he made it successfully without any issue. He finished his website in time and the website is working, has a great User Experience and good performance for a new and fresh developer in the company.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(Until then, no worries, we agree?)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/XreQmk7ETCak0/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/XreQmk7ETCak0/giphy.gif" alt="John, proud of his work." width="320" height="240"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  … then Sarah came
&lt;/h3&gt;

&lt;p&gt;Next week, Sarah, another developer of “Lorem ipsum Company” had to develop a contact module on john’s website. So, Sarah opened his favorite code editor, clone the repository of John’s website and, and……&lt;br&gt;
She was completely lost, she didn’t understand any lines of code of john’s website, and the folder structure of this project was completely a mess!&lt;br&gt;
&lt;strong&gt;So, john had to take 5 hours to explain each file and function to Sarah, they lost a total of 10 hours of work (2 * 5 hours) and made “Lorem Ipsum Company” lose money and time.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdb3w35ds2db7bi97ifkb.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdb3w35ds2db7bi97ifkb.jpg" alt="Incomprehensible code." width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The real question is: Why and How John passed a bad project to Sarah?
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;(Do you begin to understand where I’m going with the “Internal Developer Experience”, wait a minute, I will explain it in detail.)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is a schema representing the time spent by John working on his website.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F17ye4kxg3p718vpogiur.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F17ye4kxg3p718vpogiur.jpg" alt="Time spent by john working on his website.&amp;lt;br&amp;gt;
" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But … something in this schema is missing, something crucial is missing in John’s website. John does not understand why Sarah can’t work on it. John forgets about the “Internal Developer Experience”, he forgets about the best practices in terms of “working in a team” and that &lt;strong&gt;his code should not JUST be readable by himself but by ANY developers.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;So let’s take a look at John’s timeline and let’s correct this. Here is what john should have done with his project.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdyfgwajxkwkrcd97ms9n.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdyfgwajxkwkrcd97ms9n.jpg" alt="Corrected timeline.&amp;lt;br&amp;gt;
" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What a complicated timeline? Isn’t it? How can John do two things at the same time? And firstly, what’s documentation and refactoring?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Let’s start with the beginning, definitions.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code refactoring is the process of restructuring existing code into a more “readable” and often more “performant” of this code while preserving its functionality.&lt;/strong&gt; Refactoring is intended to improve the design, structure, maintainability of an existing code source while creating a much cleaner, less complex and a more architectural version of it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Foh8koat488gq7jrd6fd4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Foh8koat488gq7jrd6fd4.png" alt="Code example which isn’t refactored nor documented." width="700" height="564"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fxbpbzkcygxjof4esmd63.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fxbpbzkcygxjof4esmd63.png" alt="We extract and group the logic in an external function (ordering the code)." width="700" height="534"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;With some little refactoring session, John would have delivered a better experience to Sarah, right?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Can he do better than that? (Answer: always!)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Documentation is documentation, seems pretty obvious, but what does it mean for a developer?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fgkbdufgsloowlnuqbv8v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fgkbdufgsloowlnuqbv8v.png" alt="We have to comment our code in order to be understood—That’s all" width="700" height="646"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It sounds simple? &lt;strong&gt;Written good comments is hard&lt;/strong&gt;, it takes time, sometimes you know what you are doing, but you have difficulties to explain it, or to be sure to be understood (myself included). &lt;strong&gt;You have to be explicit about WHAT the code does and HOW it does it.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Last advice:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Your documentation needs to be ready at any time&lt;/strong&gt;, be sure not to do it the last day. Example: you get sick Monday and the delivery is Tuesday, I hope someone in your company can work on your project!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Don’t over-document:&lt;/strong&gt; The code may be self-explanatory sometimes. You should have good quality and minimal documentation in your source code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Documentation has to be part of our job as developers&lt;/strong&gt;, you have mainly two cases where you NEED to document it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The first one: The case of John and Sarah, you have to pass a project to a colleague, your code needs to be enough documented to be understood by others than yours. It seems logical, since the other developer is not in your head and not behind you when you are working in your company (I hope), he can’t completely understand the “way” you developed the project.&lt;/li&gt;
&lt;li&gt;The second one: Imagine working on a website, everything is fine again (like John’s case). One year pass, and you have to get back on this project and make adjustments on a module that you made 1 YEAR before… And you know what? You don’t understand any lines of codes! Good luck … and document it this time!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;I could have made a full article on just “refactoring” and “documentation” but this is not the main purpose of this article (maybe one day), I let you google these terms if you are looking for more information.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Even if these two methods sounds like an obligation, we often tend to forget the cons that comes with the pros:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PROS:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The code is more readable, simpler and cleaner.&lt;/li&gt;
&lt;li&gt;We ensure that we are going in the right direction when we are coding and adding comments at the same time (to know what we are doing).&lt;/li&gt;
&lt;li&gt;Passing the project to another developer is not a pain (on both sides).&lt;/li&gt;
&lt;li&gt;You could save money, time and headaches !&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;CONS:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If the code changes, you have to changes and correct the comments (nearly ever done).&lt;/li&gt;
&lt;li&gt;It takes times, refactoring and documenting your code isn't free. It cost you time and so money.&lt;/li&gt;
&lt;li&gt;If you have a short deadline, you would sometimes have to neglect the 'refactor'. Deadlines come before UX / DX and Internal Developer Experience unfortunately.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Did you remember ?&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"...Think through all of the stages of a product or service – from initial intentions through final reflections, from first usage to help, service, and maintenance. Make them all work together seamlessly." — Donald Norman&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;“From first usage to help, service, and maintenance.” &lt;strong&gt;“Maintenance” here refers directly to what we talked about (Internal Developer Experience).&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Today, I wanted to separate these three topics (UX/DX/Internal Developer Experience) but they are in a way all linked together. I hope you understood the importance of them and you will apply them in your future projects. Again, documenting a project is hard, it takes times, but the benefits are worth it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;They are all made to ensure the future of an application / website.&lt;br&gt;
UX and DX for growing and keeping the users base and the Internal Developer Experience to ensure the maintainability and the evolution of it.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Oh, one more thing!
&lt;/h3&gt;

&lt;p&gt;You can follow my adventures on social networks! 🚀&lt;/p&gt;

&lt;p&gt;You can find my social networks bellow next to the“Follow” button, &lt;strong&gt;which you should have already clicked!&lt;/strong&gt; 😎&lt;/p&gt;

&lt;p&gt;Sources: &lt;a href="https://developerexperience.io/practices/good-developer-experience"&gt;https://developerexperience.io/practices/good-developer-experience&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://css-tricks.com/what-is-developer-experience-dx/"&gt;https://css-tricks.com/what-is-developer-experience-dx/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Code_refactoring"&gt;https://en.wikipedia.org/wiki/Code_refactoring&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://blog.submain.com/how-to-document-code/"&gt;https://blog.submain.com/how-to-document-code/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>productivity</category>
      <category>ux</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
