<?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: Sudharshaun Mugundan</title>
    <description>The latest articles on DEV Community by Sudharshaun Mugundan (@ididnt_getalong).</description>
    <link>https://dev.to/ididnt_getalong</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%2F161083%2F0af461ab-8544-49d2-b82f-5b1b2f0b5544.jpg</url>
      <title>DEV Community: Sudharshaun Mugundan</title>
      <link>https://dev.to/ididnt_getalong</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ididnt_getalong"/>
    <language>en</language>
    <item>
      <title>Revealing module pattern is beautiful</title>
      <dc:creator>Sudharshaun Mugundan</dc:creator>
      <pubDate>Sat, 28 Aug 2021 06:02:59 +0000</pubDate>
      <link>https://dev.to/ididnt_getalong/revealing-module-pattern-is-beautiful-3coi</link>
      <guid>https://dev.to/ididnt_getalong/revealing-module-pattern-is-beautiful-3coi</guid>
      <description>&lt;p&gt;Revealing module pattern is one of the sub pattern of the module pattern. Don't know how many people still use module pattern in javascript, and I have seen a fair amount of code which uses RMP. &lt;/p&gt;

&lt;h3&gt;
  
  
  So what is a module pattern anyway?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The public members are exposed in the return function.&lt;/li&gt;
&lt;li&gt;The private members live in the closure.
&lt;/li&gt;
&lt;/ul&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="nx"&gt;greet&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;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Natasha&lt;/span&gt;&lt;span class="dl"&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="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;greetHello&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="s2"&gt;`Hello &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; ! Thanks for signing up!`&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="nx"&gt;greetWelcome&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="s2"&gt;`Hello &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; ! Welcome back!`&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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  How RMP is different from Module pattern?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;All the functions live in the closure.&lt;/li&gt;
&lt;li&gt;Only the functions that should be exposed are made public under return.&lt;/li&gt;
&lt;li&gt;The return functions will not have any function definitions. It will just reference the functions in the private.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;greet&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;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Natasha&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;greetHello&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="s2"&gt;`Hello &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; ! Thanks for signing up!`&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="nx"&gt;greetWelcome&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="s2"&gt;`Hello &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; ! Welcome back!`&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="na"&gt;hello&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;greetHello&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;welcome&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;greetWelcome&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;hello&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hello&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;//Hello Natasha ! Thanks for signing up!&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;welcome&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;welcome&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;//Hello Natasha ! Welcome back!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;It gives a flexibility to reference the function name with our choice. Here greetHello is the function but it is exposed as hello. This helps in a lot of scenarios, let's say you are writing an API and the module would want a function name &lt;strong&gt;saveDetailsToDB&lt;/strong&gt; for understanding the logic but not anyone who wants to use the API need that information, so you can just say

&lt;code&gt;return {save: saveDetailsToDB}&lt;/code&gt;

.&lt;/li&gt;
&lt;li&gt;Removing the key pair from the return object would make the exposed function private. Whereas in module pattern you have to remove the function from return object.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I have been a big fan of this pattern and it is just an admiration post on how beautiful it is :P &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Why to use a Front end framework/library for your application</title>
      <dc:creator>Sudharshaun Mugundan</dc:creator>
      <pubDate>Sun, 22 Mar 2020 08:10:13 +0000</pubDate>
      <link>https://dev.to/ididnt_getalong/why-to-use-front-end-framework-for-your-application-245a</link>
      <guid>https://dev.to/ididnt_getalong/why-to-use-front-end-framework-for-your-application-245a</guid>
      <description>&lt;h3&gt;
  
  
  1. Code management
&lt;/h3&gt;

&lt;p&gt;Be it a simple Todo list or a Nuclear science project you are working on, your code will get messy. You don't know where the URL came from and how it's handled after a point of time. Eventually you'll end up having &lt;strong&gt;yelling WTF is happening here syndrome&lt;/strong&gt;. But if you are stubborn on not using a framework, use ES Modules to segregate your code module wise.⚡️&lt;a href="https://www.freecodecamp.org/news/how-to-use-es6-modules-and-why-theyre-important-a9b20b480773/"&gt;Give this amazing article a read&lt;/a&gt;&lt;br&gt;
&lt;a href="https://i.giphy.com/media/xUOwGfp1V1YzLeGZHO/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/xUOwGfp1V1YzLeGZHO/giphy.gif" alt="screaming"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. We don't know to use DOM operations
&lt;/h3&gt;

&lt;p&gt;Yes. DOM operations are costly and pretty much differs from browser to browser. Manipulating and updating the DOM tree efficiently is not a piece of cake. And if your application is going to be big enough, you'll end up thinking about performance and scratch your heads.🤢&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Direct access to DOM
&lt;/h3&gt;

&lt;p&gt;It ain't a good thing to go and touch the DOM directly. So this depends on the scale of your project. If it's a smol news site which just displays the article from a CMS, cool. It's a one time change. If it's a social network where people fight their ass off and end up having millions of comments,🤕Oh boi don't touch the DOM with bare hands.&lt;br&gt;
&lt;a href="https://i.giphy.com/media/3o7TKSK8Qc7qKgehRm/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/3o7TKSK8Qc7qKgehRm/giphy.gif" alt="don-touch"&gt;&lt;/a&gt;&lt;br&gt;
Because &lt;strong&gt;DOM updation is costly&lt;/strong&gt; and only the specific DIV or a SPAN has to be updated. That's why libraries like React, Vue and so on make you create the document on their virtual DOM and they do the hard work for you using DOM diff techniques to calculate the dynamic parts of your views. At the end they too are going to query the DOM by using &lt;em&gt;document.getElementById&lt;/em&gt; and create elements with &lt;em&gt;document.createElement&lt;/em&gt;. So trust a framework on this.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. You'll end up building your own framework.
&lt;/h3&gt;

&lt;p&gt;When your application grows, it suffers from scalability. So you'll start building custom solutions for the problems and end up developing a half baked framework which might not work for the future cases coming to you.&lt;/p&gt;

&lt;p&gt;Let's say you have a templating engine like EJS and got to put the data in a bucket store. First you'll start building a data store and then it requires a middleware rendering engine to get the data efficiently to EJS. So you'll build a rendering engine. Then the routing problem comes and so on. You'll end up investing most of your time reinventing the wheel and in building the infrastructure than the application you want to build. Picking a framework that already has solved the problem you have would be a smart choice.&lt;br&gt;
&lt;a href="https://i.giphy.com/media/2kZ94kR8yDKmYbHhQ1/giphy-downsized-large.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/2kZ94kR8yDKmYbHhQ1/giphy-downsized-large.gif" alt="unnecessary efforts"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;So plan your architecture and the frameworks you want to use before starting building the application. If you are like if the application grows I'll use a framework, you might suffer from scaling.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy hacking 🚀&lt;/strong&gt;&lt;/p&gt;

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