<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Abhinav Sharma on Medium]]></title>
        <description><![CDATA[Stories by Abhinav Sharma on Medium]]></description>
        <link>https://medium.com/@abhinavsharmambm?source=rss-feb20b189b12------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*zvbu5fVeq20FkFj4</url>
            <title>Stories by Abhinav Sharma on Medium</title>
            <link>https://medium.com/@abhinavsharmambm?source=rss-feb20b189b12------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 17:44:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@abhinavsharmambm/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Algorithmic Approach in Life]]></title>
            <link>https://blog.devgenius.io/the-algorithmic-approach-in-life-e5ccb3fb0dd?source=rss-feb20b189b12------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5ccb3fb0dd</guid>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[design-process]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[datastrucutre]]></category>
            <dc:creator><![CDATA[Abhinav Sharma]]></dc:creator>
            <pubDate>Mon, 06 Jul 2020 06:09:56 GMT</pubDate>
            <atom:updated>2020-07-06T07:11:35.976Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>The Algorithmic Approach in Life-Understanding a package manager</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*x2ZFu0tis7OjXYqF" /></figure><p>We use <a href="https://en.wikipedia.org/wiki/Package_manager">package manager</a> to install packages for our project. Let’s say our project needs packages A, B, and C, and out of these A and B have some dependencies.</p><ul><li><strong>A is dependent on D</strong>, <strong>E.</strong></li><li><strong>B is dependent on F</strong>.</li><li><strong>D and E are dependent on G</strong>.</li></ul><p>Then all <strong>A, B, C, D, E, F, and G need to be installed.</strong> The package manager installs primary packages A, B, and C and all dependencies of these primary packages in the correct order.</p><p>How does it happen? Let’s try to understand in the next section.</p><h3>First, let’s try to visualize this</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/629/0*T2Et5qmj0qclrLvj" /></figure><h3><strong>First Approach for installation</strong></h3><p>We will start installing packages that are primary and directly defined in the config file and then install their dependencies and so on in a top-down manner.</p><p>For example, we will first install package A, its dependencies D, and E, and then package G will be installed. Now we will install package B and its dependency F. After this package C will be installed.</p><p>The installation order is <em>A, D, E, G, B, F, C</em></p><h3>Problem with the above approach</h3><p>To understand the problem with the above approach let’s first understand the package versioning.</p><p>If a package version is 5.4.2 then 5 is the major version, 4 is the minor version and 2 is the patch version</p><ol><li>MAJOR version change represents incompatible API changes,</li><li>MINOR version change represents functionality change in a backward-compatible manner</li><li>PATCH version change represents backward-compatible bug fixes.</li></ol><p>So If we need a package version 4.5.2 we can’t install 5.0.0 but 4.x.x is acceptable.</p><p>you can read more about this here: <a href="https://semver.org/">semantic versioning</a></p><p>Now let’s talk about a scenario</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/0*Bcgd7Qe-v9VLow-D" /></figure><p>If we see the above diagram, D requires a 5.2.1 version of G, and E requires a 6.1.0 version of G. If we start from the top, the installation order will be A, D, and E but the installation process will fail at G due to different <strong>major</strong> versions required. If there are different minor versions then a common version of G can be installed.</p><h3>Second Approach for installation</h3><p>As we saw in the previous example we can run into <a href="https://en.wikipedia.org/wiki/Dependency_hell#:~:text=Dependency%20hell%20is%20a%20colloquial,versions%20of%20other%20software%20packages.">version conflict </a>issues sometimes while installing packages. If we start from primary packages we will know about this version conflict later only when we will try to install their dependencies.</p><p>To resolve this problem, we will start the installation from a package that is not dependent on any other package, and then we will go towards primary packages in a bottom-up manner.</p><p>For example, to install primary package A installation order will be <em>G, D, E, and A.</em> This bottom-up approach will help in finding version conflict issues at the earlier stage only.</p><p><strong>From the above approaches, we can see that the installation order of packages is important, and the second approach helps us finding version conflicts issues earlier</strong>.</p><h3>Conclusion</h3><p>The intention of this blog is to give a brief overview of different approaches a package manager uses to install dependencies.</p><p>For further reading, check the below links -</p><ul><li><a href="https://www.geeksforgeeks.org/find-the-ordering-of-tasks-from-given-dependencies/?ref=rp">https://www.geeksforgeeks.org/find-the-ordering-of-tasks-from-given-dependencies/?ref=rp</a></li><li><a href="https://docs.npmjs.com/specifying-dependencies-and-devdependencies-in-a-package-json-file">https://docs.npmjs.com/specifying-dependencies-and-devdependencies-in-a-package-json-file</a></li></ul><p>Also, you can check out <a href="https://medium.com/dev-genius/the-algorithmic-approach-in-life-de0b2ecbff23">part 1</a> of this series which talks about how to find a bug in your project efficiently.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5ccb3fb0dd" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/the-algorithmic-approach-in-life-e5ccb3fb0dd">The Algorithmic Approach in Life</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Algorithmic Approach in Life]]></title>
            <link>https://blog.devgenius.io/the-algorithmic-approach-in-life-de0b2ecbff23?source=rss-feb20b189b12------2</link>
            <guid isPermaLink="false">https://medium.com/p/de0b2ecbff23</guid>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[divide-and-conquer]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Abhinav Sharma]]></dc:creator>
            <pubDate>Tue, 26 May 2020 05:45:00 GMT</pubDate>
            <atom:updated>2020-06-04T09:14:38.681Z</atom:updated>
            <content:encoded><![CDATA[<h4>Algorithms</h4><figure><img alt="Header image of the blog" src="https://cdn-images-1.medium.com/max/1024/1*ATK-AQ6S7ImVxHgw5iF_kQ.jpeg" /></figure><p>You must have solved many algorithmic problems in the past but have you ever wondered how these algorithms play an important role in our day to day life? I have always been curious about the same. And that’s why I thought of coming up with this series which is going to build your practical knowledge of algorithms by considering real-life examples.</p><p><strong>Today we are going to discuss one such example -</strong></p><p>Suppose one fine day while working on a product, you find a bug in an existing feature. Upon detailed analysis, you realize that the bug was caused by some commit in the current week because you tested this feature early this week and it was working fine. Now you need to find the commit that caused this issue and revert the changes done by it. The big challenge is how to find that bad commit.</p><h3><strong>Let’s try to first visualize this problem</strong></h3><figure><img alt="Image of visualisation of the problem" src="https://cdn-images-1.medium.com/max/831/0*WpLPO1j6pK46QYOy" /></figure><p>As we can clearly see from the diagram that once a bug is introduced subsequent commits will also have the same bug and are bad commits.<strong> The commits previous to the first bad commit will be good.</strong></p><h3>The naive approach</h3><p>One way to find the bad commit is to scan each and every commit done in the current week from the latest and going back until we find a good commit. The commit after that will be the first bad commit.</p><p>Below is the illustration of the same (G = Good commit, B = Bad commit)</p><figure><img alt="Image of the naive approach" src="https://cdn-images-1.medium.com/max/640/0*a2f9VqK3Lfn7zXrE" /></figure><p>This approach seems very easy but what are the cons of it? Imagine a big project and multiple teams contributing to it. What if we have <strong>1000</strong> commits in the current week in our code repository? It will take a lot of attempts to scan these commits and find out the first bad one using the above approach.</p><p>We can easily find out that the no of attempts in the worst case will be close to <strong>1000</strong></p><p><strong>Can we reduce our no of attempts?</strong></p><p>The answer is <strong>YES.</strong></p><p>In the above approach, we are scanning every commit sequentially until we find a good commit. We are missing an important fact here that <strong>there is a pattern in commits</strong>. If a good commit is represented by G and Bad commit is represented by B then the commit history is like GGGGGGGG………BBBBBBBBBBBBBBBB .</p><p>Based on this fact we can find the middle commit and check if it is good or bad. If the middle commit is good then our next search space will contain the commits after the middle commit. Similarly, if the middle commit is bad then our next search space will contain only commits prior to middle commit. And in this way, we optimize our approach. <strong>We are applying a<em> </em></strong><a href="https://en.wikipedia.org/wiki/Divide-and-conquer_algorithm"><strong>divide and conquer strategy </strong></a><strong>here.</strong></p><h3>The detailed optimized approach</h3><p>We can divide the initial search space into two parts and check the middle commit for 2 cases:</p><ul><li><strong>The first case is if the middle commit is a bad commit.</strong></li></ul><p>Now there are two possibilities :</p><ol><li>The commit previous to the middle commit is good then the middle commit is the first bad commit</li><li>If the previous commit is also a bad commit then our search space is reduced to all the commits before this middle commit</li></ol><ul><li><strong>The second case is if the middle commit is a good commit.</strong></li></ul><p>Now we need to only consider commits after this middle commit as prior ones are all good commits. The above process can be recursively applied to find the first bad commit.</p><p>For a better understanding below is the demonstration</p><figure><img alt="Image of the optimized approach" src="https://cdn-images-1.medium.com/max/640/0*yqCFg8P9IFVElVqe" /></figure><h3><strong>Analysis</strong></h3><p>In the above process every time we reduce our search space by half until we find the first bad commit so let’s calculate the no of attempts</p><p>Each time we are reducing the search space in half and in the worst case we will be continuing until we are left with 1 commit in search space so we can say</p><figure><img alt="Calculation of no of attempts of optimized approach" src="https://cdn-images-1.medium.com/max/660/1*hEJYiS115gDndFG9ydmQjw.png" /></figure><p>This approach is much faster than the previous approach as the number of attempts is reduced from 1000 to 10.</p><h3><strong>Conclusion</strong></h3><p>I could have also discussed the working solution of the problem but that’s not the intention of this blog. I just wanted to give insights into how we can apply our algorithmic knowledge whenever we are stuck in a real-life problem.</p><p>This is the just the starting, stay tuned for more such content 😊</p><p>For more information on the divide and conquer algorithm, check the below links -</p><ul><li><a href="https://en.wikipedia.org/wiki/Divide-and-conquer_algorithm">https://en.wikipedia.org/wiki/Divide-and-conquer_algorithm</a></li><li><a href="https://www.geeksforgeeks.org/divide-and-conquer-algorithm-introduction/">https://www.geeksforgeeks.org/divide-and-conquer-algorithm-introduction/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de0b2ecbff23" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/the-algorithmic-approach-in-life-de0b2ecbff23">The Algorithmic Approach in Life</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[User-Centric Testing in React]]></title>
            <link>https://medium.com/zendrive-tech/user-centric-testing-in-react-9ba721ac33d0?source=rss-feb20b189b12------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ba721ac33d0</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[user-experience]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Abhinav Sharma]]></dc:creator>
            <pubDate>Mon, 27 Apr 2020 10:12:18 GMT</pubDate>
            <atom:updated>2020-04-27T10:12:18.767Z</atom:updated>
            <content:encoded><![CDATA[<h4>Front-End</h4><h3>The Benefits of User-Centric Testing in React</h3><h4>Writing Maintainable Test Cases avoids several headaches</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3JL5AZIpvxe7mjTcr9h4gw.png" /></figure><p><strong><em>Writing maintainable test cases is as important as writing maintainable code</em></strong><em>.</em> I realized this last year while working on a couple of features in our <strong>Dashboard</strong> built using <strong>React</strong>.</p><p>Every time I worked on new functionality, the existing functionality worked as expected but the related test cases were red. I had to spend a couple of hours fixing them. This resulted in loss of motivation to write new test cases as well as fix the existing ones.</p><p>One day, I decided to identify the root cause of this problem.</p><h3>Approach</h3><p>To understand the issues with the testing approach we first need to understand it with an example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c915dbfde60371f8153ab824f7fcb736/href">https://medium.com/media/c915dbfde60371f8153ab824f7fcb736/href</a></iframe><p>Let us write test cases for the <strong><em>UserForm component</em></strong> using the conventional testing approach.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dcf249425565fecd161c259211e3f611/href">https://medium.com/media/dcf249425565fecd161c259211e3f611/href</a></iframe><h4>Problems</h4><p>The most notable issues are:</p><p><strong>Readability<br></strong>The test description is not sufficient enough to tell what purpose it solves.</p><p><strong>Tight coupling with component code</strong><br>Test implementation relies heavily on the component internal state which makes refactoring a nightmare. Imagine changing error to errorName. We need to fix tests separately apart from fixing the component.</p><p><strong>A false sense of security</strong><br>Green test cases give a false sense of security that the application will work correctly in production, which might not be the case.</p><p>So what’s fundamentally wrong with this testing approach?</p><p><strong><em>It heavily depends on the component’s implementation and is far away from testing how a user interacts with the component.</em></strong></p><h4>Solution</h4><p>What can we do to solve all of the issues above? We need a testing approach in which tests are written keeping the user in the center. That’s where the User-Centric testing comes into the picture.</p><p><strong><em>Write test cases for your application similar to how the user interacts with it.</em></strong></p><p>But how can we write tests which are more user-centric?</p><ol><li>Whenever we write a test we should always think about the end-user and avoid caring about the component internals.</li><li>We need a testing library that encourages user-centric testing practices and that’s where <a href="https://testing-library.com/docs/react-testing-library/intro">React testing-library</a> shines.</li></ol><p>Let’s rewrite the test cases for <strong><em>UserForm Component</em></strong> keeping user-centric testing practices in mind and using react-testing-library</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4fbddd82b48c692792ad08a0c9eecd13/href">https://medium.com/media/4fbddd82b48c692792ad08a0c9eecd13/href</a></iframe><p>Now we are using placeholders, labels, and asserting for actual error message shown to the user in our test cases.</p><p><strong><em>These tests are more readable, decoupled from component internals, and give you more confidence that the application will work when a real user uses it.</em></strong></p><p>So did we rewrite all our tests for the <strong>dashboard</strong>?</p><p><strong><em>No.</em></strong></p><p>At the time, we didn’t have the bandwidth to rewrite tests. We just learned our lesson and decided to use the user-centric testing approach in the future.</p><h3><strong>Conclusion</strong></h3><p>Once again, I say<strong><em> “Writing maintainable test cases is as important as writing maintainable code”</em></strong> and user-centric testing helps with that. However, the adoption of this technique may differ from case to case.</p><p>If you have an application that has no test cases, you can start straight away with the user-centric testing approach and follow it throughout the project.</p><p>If you have an application with some test coverage then you can follow a hybrid approach, i.e. you can keep the old test cases as they are while adopting the user-centric testing approach for new functionality.</p><h3>Want More Info? Here’s some reading material:</h3><ul><li><a href="https://testing-library.com/docs/react-testing-library/intro">React Testing Library | Testing Library</a></li><li><a href="https://kentcdodds.com/blog/introducing-the-react-testing-library">Introducing the react-testing-library 🐐</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ba721ac33d0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/zendrive-tech/user-centric-testing-in-react-9ba721ac33d0">User-Centric Testing in React</a> was originally published in <a href="https://medium.com/zendrive-tech">Zendrive Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Oft-Ignored Art of Email Design]]></title>
            <link>https://medium.com/zendrive-tech/the-oft-ignored-art-of-email-design-704441aeb9a0?source=rss-feb20b189b12------2</link>
            <guid isPermaLink="false">https://medium.com/p/704441aeb9a0</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Abhinav Sharma]]></dc:creator>
            <pubDate>Thu, 16 Jan 2020 18:57:41 GMT</pubDate>
            <atom:updated>2020-01-17T04:46:24.764Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bm0Y-qjNfa4dHzbTT54q_w.png" /></figure><p><strong>Mid-September 2019</strong>: We got a requirement to build new transactional emails for an existing product, which gave me a reason to look at our existing templates.</p><p>I was really shocked at what I found. The code was full of tables like it was a web page from the 1990s. This was just a poor way to achieve responsive design.</p><blockquote>“A responsive email is an email that looks good on any device, whether it’s a desktop, tablet, or mobile phone. The email automatically adapts to all screen resolutions.”</blockquote><p>Some of the most popular email clients, like Outlook, don’t work well with div-based layouts. Other email clients like Gmail strip out style tags. Because of this, we had been using table-based designs.</p><p>Designing a responsive email is an art and as web developers, we need to master it.</p><h3><strong>Principles We Kept In Mind</strong></h3><p>We knew we didn’t want to continue using our templates, because developers need to be aware of quirks of email formatting and need to manage tools for inlining styles etc.</p><p>We wanted to build a setup keeping in mind that:</p><ul><li><strong>Our team of front-end developers should love to work with it.</strong> Their focus should be building the best email possible, not worrying about renders in different email clients. Email templates should use the same principles and elements of normal webpage development.</li><li>The setup should<strong> support reusability.</strong> Common elements such as headers and footers should be easily available.</li><li>The setup should give developers the ability to <strong>implement pixel-perfect designs.</strong></li></ul><p>Keeping these principles in mind, we started exploring different frameworks.</p><h3>Approaches We Considered</h3><p>Two of the most popular and interesting frameworks available were <strong>MJML</strong> and <strong>Foundation For Emails.</strong></p><p>MJML has pre-built components for reuse, but it’s less reliable than Foundation for pixel-perfect designs. Also, it does not come with a structured set of folders.</p><p>Foundation, on the other hand, has its own command-line interface, foundation-cli, which generates a base folder structure with support for reusability. The scripts to convert inky HTML (foundation tags) to table-based layouts, CSS inlining, etc. is also baked into the above structure.</p><p>These scripts can easily be customized to suit different needs. It allows developers the flexibility to implement pixel-perfect designs.</p><p>As Foundation For Email satisfied most of the things from the above checklist, we decided to use it for our email build setup.</p><h3><strong>Our Setup using Foundation-CLI</strong></h3><p>We used foundation-cli for the project setup. The generated project has a structure as follows:</p><ul><li><strong>Assets</strong>: Sass and image files.</li><li><strong>Layouts</strong>: Boilerplate HTML that wraps all of your emails.</li><li><strong>Pages</strong>: HTML files for emails.</li><li><strong>Partials</strong>: Reusable chunks of HTML that can be injected into pages.</li></ul><p>This structure has all the scripts backed in to generate email client compatible HTML from source HTML. The whole process works as described below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7yakD6Jqr2oKmGgbtKLq-A.jpeg" /></figure><ol><li>A page that contains base HTML for a particular email is<strong> </strong>assembled<strong> </strong>with<strong> </strong>partials like header and footer and layout.</li><li>This assembled code is converted to a table-based HTML.</li><li>In parallel, SCSS files are converted to CSS and then inlined with the table structure (added as style attribute on elements) to generate the final responsive email content.</li></ol><p>Inlining is needed to avoid style tag strip issues in Gmail and similar clients.</p><h3><strong>What We Learned</strong></h3><p>We’ve migrated all our existing email templates and are building new ones using this setup. The developer experience has been very good, and we’re now able to build templates faster.</p><p>Producing email templates is not an exact science. It requires a lot of trial and error and a lot of testing. Whatever tool you use, you will need to test your layouts ad nauseam, especially if you need to support old clients, and if your emails have even the smallest degree of complexity.</p><p>For example, if you have a text that needs to sit beside an image, you will run into alignment issues. I recommend testing with content at different lengths and see what happens in all clients.</p><p>I wouldn’t say that one framework is better than the other and that’s not the point of this post. Rather, I would recommend MJML and Foundation for Emails for different use cases:</p><ul><li>MJML is better for projects that have a quick turnaround and there is flexibility in the design.</li><li>Foundation for Emails is better for projects that require tighter control over the layout and where the design is super-specific.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=704441aeb9a0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/zendrive-tech/the-oft-ignored-art-of-email-design-704441aeb9a0">The Oft-Ignored Art of Email Design</a> was originally published in <a href="https://medium.com/zendrive-tech">Zendrive Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>