<?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: Mohaiminul Shovon</title>
    <description>The latest articles on DEV Community by Mohaiminul Shovon (@mohaiminul_shovon).</description>
    <link>https://dev.to/mohaiminul_shovon</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%2F1008530%2Fdb01ba91-2523-4a34-82ca-2bae586626bd.jpg</url>
      <title>DEV Community: Mohaiminul Shovon</title>
      <link>https://dev.to/mohaiminul_shovon</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mohaiminul_shovon"/>
    <language>en</language>
    <item>
      <title>how to use AI to create automation testing with playwirght</title>
      <dc:creator>Mohaiminul Shovon</dc:creator>
      <pubDate>Wed, 05 Feb 2025 11:43:59 +0000</pubDate>
      <link>https://dev.to/mohaiminul_shovon/how-to-use-ai-to-create-automation-testing-with-playwirght-2005</link>
      <guid>https://dev.to/mohaiminul_shovon/how-to-use-ai-to-create-automation-testing-with-playwirght-2005</guid>
      <description></description>
      <category>ai</category>
      <category>automation</category>
      <category>testing</category>
      <category>playwright</category>
    </item>
    <item>
      <title>Really useful tips to organize the test suite.</title>
      <dc:creator>Mohaiminul Shovon</dc:creator>
      <pubDate>Wed, 22 Jan 2025 03:22:06 +0000</pubDate>
      <link>https://dev.to/mohaiminul_shovon/really-useful-tips-to-organize-the-test-suite-40e7</link>
      <guid>https://dev.to/mohaiminul_shovon/really-useful-tips-to-organize-the-test-suite-40e7</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/playwright" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__org__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%2Forganization%2Fprofile_image%2F6222%2F2467899f-c222-4218-9f92-b3e3d6c1f4f5.png" alt="Playwright end to end Testing" width="400" height="400"&gt;
      &lt;div class="ltag__link__user__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%2F212929%2F947ba7e0-41fe-464a-a4f3-abb66a3170c6.jpg" alt="" width="800" height="648"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/playwright/organizing-playwright-tests-effectively-2hi0" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Organizing Playwright Tests Effectively&lt;/h2&gt;
      &lt;h3&gt;Debbie O'Brien for Playwright end to end Testing ・ Jan 21&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#testing&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#playwright&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#webdev&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#javascript&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>testing</category>
      <category>playwright</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Clean Coding Essentials: Tips for Writing Readable Code</title>
      <dc:creator>Mohaiminul Shovon</dc:creator>
      <pubDate>Wed, 30 Oct 2024 11:36:16 +0000</pubDate>
      <link>https://dev.to/mohaiminul_shovon/clean-coding-essentials-tips-for-writing-readable-code-3mn4</link>
      <guid>https://dev.to/mohaiminul_shovon/clean-coding-essentials-tips-for-writing-readable-code-3mn4</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;“Any fool can write code that a computer can understand. Good programmers write code that humans can understand.”&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Martin Fowler’s quote captures the essence of clean coding: creating code that’s functional and easy for other developers to read. In the line duty, I myself has faced numerous challenges while writing code. But It was never the technical things that make me concerned. It the cleanliness and readability of my code. Here’s my take on clean coding principles that might help to maintain utmost readability of the code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Naming Variables
&lt;/h2&gt;

&lt;p&gt;Good variable names are critical for clear, maintainable code. &lt;/p&gt;

&lt;p&gt;According to the famous software nerd Phil Karlton,&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"There are only two hard things in Computer Science: cache invalidation and naming things."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here’s how to improve your naming practices:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Avoiding Disinformation&lt;/strong&gt;: Use variable names that accurately describe what they hold. Avoid misleading terms.

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bad&lt;/strong&gt;: &lt;code&gt;int hp; // Is it hit points or horsepower?&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Good&lt;/strong&gt;: &lt;code&gt;int hitPoints;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Avoiding Noise Words&lt;/strong&gt;: Words like "data" or "info" add clutter and don’t clarify what the variable holds.

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bad&lt;/strong&gt;: &lt;code&gt;string productInfo;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Good&lt;/strong&gt;: &lt;code&gt;string productName;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Using Pronounceable Names&lt;/strong&gt;: Names should be easy to read and say out loud.

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bad&lt;/strong&gt;: &lt;code&gt;string prdctNm;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Good&lt;/strong&gt;: &lt;code&gt;string productName;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Using Searchable Names&lt;/strong&gt;: Avoid short, non-descriptive names that make it hard to locate variables.

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bad&lt;/strong&gt;: &lt;code&gt;for (int i = 0; i &amp;lt; 10; i++) { ... }&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Good&lt;/strong&gt;: &lt;code&gt;for (int itemIndex = 0; itemIndex &amp;lt; items.Count; itemIndex++) { ... }&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Be Consistent&lt;/strong&gt;: Stick to a single naming convention throughout.

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Inconsistent&lt;/strong&gt;: &lt;code&gt;userName&lt;/code&gt; in one place and &lt;code&gt;user_name&lt;/code&gt; in another.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Consistent&lt;/strong&gt;: Always use &lt;code&gt;userName&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Writing Functions
&lt;/h2&gt;

&lt;p&gt;Writing clean, effective functions is essential for readability and maintainability.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Keeping Functions Small&lt;/strong&gt;: Short functions are easier to understand. Aim to fit each function on one screen.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Bad&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;calculateTotal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="c1"&gt;# Several lines of calculation logic
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Good&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;calculateItemTotal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="bp"&gt;...&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;calculateCartTotal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nf"&gt;calculateItemTotal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Single Responsibility&lt;/strong&gt;: Each function should do only one thing.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Bad&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;sendEmail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;subject&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Sending email to &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="c1"&gt;# Code to send email
&lt;/span&gt;    &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Email sent&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Good&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;logMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;sendEmail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;subject&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="c1"&gt;# Code to send email
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Encapsulate Conditionals in Functions&lt;/strong&gt;: Long, complex conditionals are confusing. Encapsulate them with clear function names.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Bad&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isActive&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isVerified&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;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Good&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;isUserEligible&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&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="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isActive&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isVerified&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="nf"&gt;isUserEligible&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&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;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Fewer Arguments&lt;/strong&gt;: Aim for functions with three or fewer parameters.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Bad&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;createUser&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="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;address&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;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Good&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;createUser&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="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;address&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;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Avoid Flag Arguments&lt;/strong&gt;: Flags complicate function logic.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Bad&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;displayUserProfile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;isAdmin&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="nx"&gt;isAdmin&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Show admin view&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Show regular view&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;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Good&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;displayUserProfile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&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;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;displayAdminProfile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&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;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;No Side Effects&lt;/strong&gt;: Functions should not alter external states unless intended.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Bad&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;addToCart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// modifies an external cart&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&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;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Good&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;createUpdatedCart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;item&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;updatedCart&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;item&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;updatedCart&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;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Don’t Repeat Yourself (DRY)&lt;/strong&gt;: Avoid duplicating logic. Reuse functions wherever possible.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Bad&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calculateDiscountedPrice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;price&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="nx"&gt;price&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;price&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.1&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;calculateFinalPrice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;price&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="nx"&gt;price&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;price&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Duplicate logic&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Good&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;applyDiscount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;price&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;discountRate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.1&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="nx"&gt;price&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;price&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;discountRate&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;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Don’t Leave Code in Comments
&lt;/h2&gt;

&lt;p&gt;Comments can be helpful, but avoid leaving commented-out code. It adds clutter and can mislead readers.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Bad&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# This is a function to add two numbers
# def add(a, b):
#     return a + b
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Good&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Function to add two numbers
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Know Your Language Conventions
&lt;/h2&gt;

&lt;p&gt;Each language has unique conventions for naming, indentation, and structure. Following them improves consistency and readability.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;JavaScript Example&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Follow camelCase for variables and functions&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;userName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;John Doe&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Use PascalCase for classes&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UserProfile&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;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Python Example&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Use snake_case for variables and functions
&lt;/span&gt;&lt;span class="n"&gt;user_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;John Doe&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="c1"&gt;# Use CapitalizedWords for classes
&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UserProfile&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="bp"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Clean coding practices are an investment that pays off with better readability, easier maintenance, and a codebase that other developers will thank you for. Start with these practices to make your code cleaner, clearer, and more effective.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Random Data Generation for API Test Automation Using Faker</title>
      <dc:creator>Mohaiminul Shovon</dc:creator>
      <pubDate>Fri, 26 Jul 2024 10:40:58 +0000</pubDate>
      <link>https://dev.to/mohaiminul_shovon/random-data-generation-for-api-test-automation-using-faker-1ef</link>
      <guid>https://dev.to/mohaiminul_shovon/random-data-generation-for-api-test-automation-using-faker-1ef</guid>
      <description>&lt;p&gt;Whenever we automation engineers try to create a API chaining requests, the most common obstacle and responses we get from the API is “Content Already Exists!”. Well our test has passed, but we need to move on from there. How? For the newbies, it’s a million dollar problem. Let’s take a scenario to understand the dilemma here.&lt;/p&gt;

&lt;p&gt;We have an API in our hand which actually creates a user with some details such as gender, nationality, age, etc. We give a JSON body such as this to the API to process.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
”name”: “Mr. X”, 
“age”: 25, 
“gender”: “male”, 
“nationality”: “Japanese”
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, the processes the body and send back a response, “New user created”. But we are in a automation journey. We can’t provide this same name and details every time our scripts run. Otherwise It will give back “Already created!”. &lt;/p&gt;

&lt;p&gt;For this kind of test scenarios where we need to give dynamic data for each iteration. There are multiple ways to dynamically give data to request body. We can manually create some random data for this and store in a CSV file. For each iteration, we will pick from that CSV file. But this process is a manual process inside an automation process which we don’t want. There is another excellent way we can achieve our goal.&lt;/p&gt;

&lt;p&gt;One excellent way to generate random data for API testing is by using the Faker library with TypeScript. Faker is a widely-used library that can generate fake data for various fields such as names, addresses, phone numbers, and more. Here's how you can use Faker with TypeScript to create dynamic data for your API tests.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installing Faker
&lt;/h3&gt;

&lt;p&gt;First, you need to install the Faker library. You can do this using npm:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install @faker-js/faker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Using Faker in TypeScript
&lt;/h3&gt;

&lt;p&gt;Once the installation is complete, you can use Faker to generate fake data in your TypeScript code. Below is an example of how you can use Faker to generate dynamic data for the user creation scenario:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { faker } from '@faker-js/faker';

// Function to create a fake user
function createFakeUser() {
  const name = faker.name.findName();
  const age = faker.datatype.number({ min: 18, max: 100 });
  const gender = faker.name.gender(true); // Generates 'male' or 'female'
  const nationality = faker.address.country();

  return {
    name: name,
    age: age,
    gender: gender,
    nationality: nationality
  };
}

// Generate a new fake user
const fakeUser = createFakeUser();
console.log(fakeUser);

// Example of how you might use this fake user data in an API request
const requestBody = JSON.stringify(fakeUser);

// Now you can send this requestBody in your API request
// For example, using fetch or axios
// fetch('your-api-endpoint', { method: 'POST', body: requestBody });



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the createFakeUser function generates a new user object with a random name, age, gender, and nationality each time it is called. You can then use this object as the request body for your API tests, ensuring that each test run uses unique data and avoids the "Content Already Exists!" issue.&lt;/p&gt;

</description>
      <category>faker</category>
      <category>randomdatageneration</category>
      <category>typescript</category>
      <category>testautomation</category>
    </item>
    <item>
      <title>Software Bug Inspection: From Mytery to Mastery!</title>
      <dc:creator>Mohaiminul Shovon</dc:creator>
      <pubDate>Tue, 14 Mar 2023 11:45:30 +0000</pubDate>
      <link>https://dev.to/mohaiminul_shovon/software-bug-inspection-from-mytery-to-mastery-22jc</link>
      <guid>https://dev.to/mohaiminul_shovon/software-bug-inspection-from-mytery-to-mastery-22jc</guid>
      <description>&lt;p&gt;Finding bug is the sole responsibility of a software tester🕵️‍♀️ but is it all a tester should do? Most of the tester encounter a lot of hazardous bugs🐞 but some of them go a little further with this. They just put it up in bug tracking software and be gone to find some more. A proper tester will always put an effort to make the bugs more presentable and understandable for the developer who will eventually solve the bug. That’s where we get into investigation of bug.&lt;/p&gt;

&lt;p&gt;In an article named "&lt;a href="https://www.eviltester.com/blog/eviltester/rackets/016-how-far-to-investigate-defect/" rel="noopener noreferrer"&gt;How far to investigate&lt;/a&gt;",  it has been said,&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;"If people have to ask a lot of questions about the defects raised in order to fix them then, you have not gone far enough. Go as far as you can, while you are still adding value to the person who is following."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;🤷‍♀️Investigating a bug can be a complex and time-consuming process, but it is an essential part of the software development cycle. The goal of investigating a bug is to identify the root cause, implement a solution, and prevent the bug from recurring. Let's see some common methods to go by when we try to investigate a bug.&lt;/p&gt;

&lt;p&gt;First, it is important to reproduce the bug. Reproducing the bug will confirm its existence and provide a starting point 🔦 for the investigation. It is also important to gather as much information as possible about the bug, including the steps to reproduce it, the environment in which it occurs, and any error messages or other output that might be relevant.&lt;/p&gt;

&lt;p&gt;Secondly, it is important to determine the scope of the bug. Is the bug affecting only one user or system👨, or is it impacting multiple users or systems👨👨👨? Understanding the scope of the bug will help you prioritize your efforts and determine the impact 💣 of the bug.&lt;/p&gt;

&lt;p&gt;Once you have a clear understanding of the bug, you can begin to isolate🧲 the root cause. This can involve breaking down the problem into smaller parts and eliminating potential causes one by one. Using debugging tools, such as debuggers and log files, can also be helpful in isolating the root cause.&lt;/p&gt;

&lt;p&gt;As you investigate the bug, it is important to consider the trade-offs between the time 🕒 and resources 🔧 required to investigate the bug and the potential impact of the bug. For example, a bug that is causing significant problems for users or causing financial losses may warrant a more extensive investigation. However, a minor bug that has little impact on users may not require as much investigation.&lt;/p&gt;

&lt;p&gt;🔊Effective communication with developers, product managers, and other stakeholders is also crucial in the investigation process. It is important to keep these stakeholders🧔 informed about the progress of the investigation🕵️‍♂️ and the potential impact of the bug.&lt;/p&gt;

&lt;p&gt;In summary, investigating a bug can be a complex and time-consuming process, but it is an essential part of ensuring the quality of a software. By reproducing the bug, determining the scope, isolating the root cause, using debugging tools, prioritizing efforts, and effectively communicating with stakeholders, you can efficiently make sense❗❗ out of a bug.&lt;/p&gt;

</description>
      <category>bug</category>
      <category>rootcauseanalysis</category>
      <category>testing</category>
      <category>buginvestigation</category>
    </item>
  </channel>
</rss>
