<?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: Afia</title>
    <description>The latest articles on DEV Community by Afia (@afiaanjumpreety).</description>
    <link>https://dev.to/afiaanjumpreety</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%2F536251%2Fd9ed01a4-673c-41e3-b874-80df7f81d702.jpg</url>
      <title>DEV Community: Afia</title>
      <link>https://dev.to/afiaanjumpreety</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/afiaanjumpreety"/>
    <language>en</language>
    <item>
      <title>𝐖𝐫𝐢𝐭𝐢𝐧𝐠 𝐂𝐥𝐞𝐚𝐧 𝐂𝐨𝐝𝐞𝐬</title>
      <dc:creator>Afia</dc:creator>
      <pubDate>Fri, 29 Sep 2023 12:23:49 +0000</pubDate>
      <link>https://dev.to/afiaanjumpreety/-1ef8</link>
      <guid>https://dev.to/afiaanjumpreety/-1ef8</guid>
      <description>&lt;p&gt;Last week, our current Technical Manager gave a shoutout to both my colleague and me during the SCRUM meeting for consistently maintaining clean coding standards in each of our Pull Requests (PRs). However, I believe it's important to acknowledge the contributions of our Technical Manager and our colleagues who have been helping us in our clean coding journey.&lt;/p&gt;

&lt;p&gt;From the beginning, when we joined the project, our Technical Manager provided clear guidance on the non-negotiable clean coding criteria that he expected us to maintain. He conducted two hands-on sessions with us, where we collaboratively worked on the existing codebase.&lt;/p&gt;

&lt;p&gt;Furthermore, credit is due to our colleagues who diligently reviewed our PRs. They thoroughly checked if we had missed anything mentioned below and provided feedback for further improvements.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The Clean Coding techniques that we strictly followed on our Angular project are following-&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Removing Magic Strings
&lt;/h3&gt;

&lt;p&gt;To avoid hardcoded values throughout our code, we used constants or enums to replace magic strings, storing them in designated local and global constant files as needed. &lt;/p&gt;

&lt;p&gt;This approach made it easier to update and ensured consistency throughout the codebase. &lt;/p&gt;

&lt;p&gt;For example, instead of using a magic string like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="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%2Farticles%2Fvake2pvs6hfiwqt3wh8m.png" class="article-body-image-wrapper"&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%2Farticles%2Fvake2pvs6hfiwqt3wh8m.png" alt="magic_string_don'ts" width="800" height="304"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can use a constant or enum:&lt;br&gt;
&lt;a href="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%2Farticles%2Ftqz4e384f97gypq45o8e.png" class="article-body-image-wrapper"&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%2Farticles%2Ftqz4e384f97gypq45o8e.png" alt="magic_string_do's" width="800" height="536"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Adding Comments
&lt;/h3&gt;

&lt;p&gt;We documented our code using JSDoc comments. To streamline this process, we utilized the "𝘢𝘥𝘥 .𝘫𝘴𝘥𝘰𝘤" command with the help of ChatGPT, making the code self-explanatory.&lt;/p&gt;

&lt;p&gt;Also, tried to avoid including unnecessary comments.&lt;/p&gt;

&lt;p&gt;&lt;a href="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%2Farticles%2Fog8wa6iamnpnpw9xl8bf.png" class="article-body-image-wrapper"&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%2Farticles%2Fog8wa6iamnpnpw9xl8bf.png" alt="adding_jsdocs" width="800" height="479"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Breaking Larger Functions into Small Chunks
&lt;/h3&gt;

&lt;p&gt;Breaking down large, complex code into smaller, more manageable functions, essentially modularizing the code. It also helped us not to repeat any code.&lt;/p&gt;

&lt;p&gt;Adding comments using JSDoc made the process quite easier.&lt;/p&gt;

&lt;p&gt;&lt;a href="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%2Farticles%2F5h2fefq723dje6jlavg0.png" class="article-body-image-wrapper"&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%2Farticles%2F5h2fefq723dje6jlavg0.png" alt="modularization" width="800" height="527"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Naming
&lt;/h3&gt;

&lt;p&gt;NO abbreviations or spelling mistakes were allowed. It is okay if the function name gets longer and a little bit descriptive as long as it matches the purpose of the function properly.&lt;/p&gt;

&lt;p&gt;&lt;a href="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%2Farticles%2Fwk84vx953y1s62aq9vbt.png" class="article-body-image-wrapper"&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%2Farticles%2Fwk84vx953y1s62aq9vbt.png" alt="naming_convention" width="800" height="408"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Avoiding "any" Type
&lt;/h3&gt;

&lt;p&gt;We tried specifying proper TypeScript types for function parameters and return values. &lt;/p&gt;

&lt;p&gt;Initially, we focused on cleaning some parts of the existing codebase, which I found a bit more challenging than maintaining it in my own code.&lt;/p&gt;

&lt;p&gt;&lt;a href="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%2Farticles%2Flxvg8erew0jwgcoqkuve.png" class="article-body-image-wrapper"&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%2Farticles%2Flxvg8erew0jwgcoqkuve.png" alt="avoiding_any_type" width="800" height="541"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Using Code Formatter
&lt;/h3&gt;

&lt;p&gt;We used &lt;strong&gt;&lt;em&gt;prettier&lt;/em&gt;&lt;/strong&gt; to maintain a consistent code style across the project.&lt;/p&gt;

&lt;h3&gt;
  
  
  7. Mentioning Proper Return Type
&lt;/h3&gt;

&lt;p&gt;Regarding proper return types, as mentioned earlier, we made an effort to specify the return type of functions, including void for functions that didn't return anything.&lt;/p&gt;

&lt;p&gt;&lt;a href="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%2Farticles%2F9qc4706x377oigziwqgp.png" class="article-body-image-wrapper"&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%2Farticles%2F9qc4706x377oigziwqgp.png" alt="return_type" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  8. Using Access Modifier
&lt;/h3&gt;

&lt;p&gt;Used access modifiers like "private" for functions not used in templates to improve code encapsulation and readability&lt;/p&gt;

&lt;p&gt;&lt;a href="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%2Farticles%2F7w3a2xbr2qgkij39ihvz.png" class="article-body-image-wrapper"&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%2Farticles%2F7w3a2xbr2qgkij39ihvz.png" alt="access_modifier" width="800" height="383"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>cleancode</category>
      <category>javascript</category>
    </item>
    <item>
      <title>𝗗𝗼𝘂𝗯𝗹𝗲 𝗡𝗲𝗴𝗮𝘁𝗶𝗼𝗻 (!!)</title>
      <dc:creator>Afia</dc:creator>
      <pubDate>Sun, 17 Sep 2023 13:57:06 +0000</pubDate>
      <link>https://dev.to/afiaanjumpreety/-40m9</link>
      <guid>https://dev.to/afiaanjumpreety/-40m9</guid>
      <description>&lt;p&gt;&lt;a href="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%2Farticles%2Fzdk1n4oqwzsb4owoflfb.png" class="article-body-image-wrapper"&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%2Farticles%2Fzdk1n4oqwzsb4owoflfb.png" alt="Image description" width="800" height="497"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Have you ever come across the &lt;code&gt;!!&lt;/code&gt; or "not not" operator? &lt;br&gt;
Well, I encountered it this morning.&lt;/p&gt;

&lt;p&gt;In hashtag #JavaScript, using the double negation (!!) in front of a value or expression is &lt;em&gt;a shorthand technique to convert a value into its boolean equivalent.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const falsyValue = NaN;
const truthyValue = 'JavaScript';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;code&gt;!&lt;/code&gt; means NOT.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;first&lt;/strong&gt; &lt;code&gt;!&lt;/code&gt; (not) operator converts a value into a Boolean and reverses it, changing truthy values to &lt;code&gt;false&lt;/code&gt; and falsy values (e.g., &lt;code&gt;false&lt;/code&gt;, &lt;code&gt;0&lt;/code&gt;, &lt;code&gt;null&lt;/code&gt;, &lt;code&gt;undefined&lt;/code&gt;, &lt;code&gt;NaN&lt;/code&gt;, or an empty string) to &lt;code&gt;true&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;!falsyValue; // true
!truthyValue // false
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;second&lt;/strong&gt; &lt;code&gt;!&lt;/code&gt; operator negates the result of the first &lt;code&gt;!&lt;/code&gt;operation, converting the value back to its original boolean representation. If the original value is truthy, it remains &lt;code&gt;true&lt;/code&gt; after the double negation, and if it is falsy, it becomes &lt;code&gt;false&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;!!falsyValue; // false
!!truthyValue // true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>funfacts</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
