<?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 Dollar Dhingra on Medium]]></title>
        <description><![CDATA[Stories by Dollar Dhingra on Medium]]></description>
        <link>https://medium.com/@dollardhingra?source=rss-f9fdbac0bae6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*N1jpVKSob28cENC7uXexsQ.jpeg</url>
            <title>Stories by Dollar Dhingra on Medium</title>
            <link>https://medium.com/@dollardhingra?source=rss-f9fdbac0bae6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 05:04:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dollardhingra/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[Bus Factor in Software Engineering]]></title>
            <link>https://medium.com/analytics-vidhya/bus-factor-in-software-engineering-d3316279ea41?source=rss-f9fdbac0bae6------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3316279ea41</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[project-management]]></category>
            <category><![CDATA[best-practices]]></category>
            <dc:creator><![CDATA[Dollar Dhingra]]></dc:creator>
            <pubDate>Fri, 21 Jan 2022 18:30:00 GMT</pubDate>
            <atom:updated>2022-02-25T16:35:42.744Z</atom:updated>
            <content:encoded><![CDATA[<p>Imagine that John Doe works on a project along with 7–10 folks. John started working on this project from the beginning and therefore knows a lot more than everyone else in the project.</p><p>These leads to some problems such as:</p><ol><li>John is the go-to person for each detail that the team needs. John has a lot of responsibility and workload on his shoulders, making his progress sometimes slow.</li><li>Whenever John falls sick and goes on unplanned leave, he is bugged by his team to keep things moving forward in the project.</li><li>The organisation finds it hard to replace John and has therefore retained him twice in the past year by raising his compensation twice.</li></ol><blockquote><em>In short, the project has a single point of failure -&gt; John Doe</em></blockquote><p>As per Wikipedia, The bus factor is a measurement of the risk resulting from information and capabilities not being shared among team members, derived from the phrase “in case they get hit by a bus”. It is also known as the bread truck scenario, bus problem, beer truck scenario, lottery factor, truck factor, bus/truck number, or lorry factor.</p><p>In simple words, what is the probability of the project failing if John Doe gets hit by a bus and is not able to return to work?</p><blockquote><em>Higher the bus factor higher the risk of failure.</em></blockquote><h3>3.1 Documenting</h3><p>Creating and maintaining documentation can take a good amount of effort from all the stakeholders. But in the long run, it is worth documenting. Documenting includes Product Requirement Documents(PRDs), High &amp; Low-level design documents, changelogs, READMEs, complete ticket descriptions on ticketing tools, Root Cause Analysis documents in case of production fires, etc</p><h3>3.2 Code Reviews</h3><p>If done effectively, code reviews can act as an excellent tool to reduce the bus factor, given that everyone in the team gets a chance to review the code. The Engineering manager/team lead should make sure that there are relative code review guidelines set up as per the team so that it is effective enough.</p><h3>3.3 Meetings</h3><p>Yes, I know meetings sometimes slow us down and hinder our productivity. Also, some meetings can just be replaced by an email. But, meetings (especially if you are working remotely) can actively reduce the bus factor if done correctly. Meetings like standup, sprint planning/grooming, design discussions, sprint retros etc bring everyone together as a team. Imagine you reading a minute of meeting document vs actually brainstorming in the meeting. <strong>Meetings do not replace the documentation. Instead, the documentation complements the meeting process.</strong></p><h3>3.4 Team Process</h3><p>More team processes can improve the knowledge distribution in the team like:</p><ul><li>Pair programming</li><li>Office hours</li><li>On-call rotations</li><li>Engineering demos</li><li>Knowledge sharing sessions</li></ul><h3>3.5 Positive Work culture</h3><p>A positive culture means employees are happy in the organisation and a better work environment is created. Following techniques can be applied to improve the work culture and reduce the bus factor:</p><h3>3.5.1 Mandatory Paid Annual Vacation</h3><p>Most of the organisations provide paid leave to their employees. The organisations should also encourage people to use these leaves and go on a vacation(for a week at least). This will enable other employees to take care of work in the absence of an employee.</p><h3>3.5.2 Short Notice/Termination Period</h3><p>A short notice period means, the organisation making sure that there is less dependency on an employee.</p><p>The first step is to talk about Bus factor in your team, even if you are a junior member in the team. Maybe, some of the above methods like meetings, code reviews, documenting etc. are already being used in your organisation for sharing knowledge. You can consider optimising those methods to reduce/prevent the bus factor in your team. For eg, you can consider including the junior members of your team in meetings and code reviews. The members with a centralized knowledge can work on spreading their knowledge in the team so that they can spend their time and energy on something new for the team.</p><p>What do you think of Bus factor in your team? Do you have more methods to prevent high bus factor? Feel free to give your feedback!</p><p><em>Originally published at </em><a href="https://dollardhingra.com/blog/bus-lottery-factor-software-engineering/"><em>https://dollardhingra.com</em></a><em> on January 21, 2022.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3316279ea41" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/bus-factor-in-software-engineering-d3316279ea41">Bus Factor in Software Engineering</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[#1 Python Anti-Pattern — Mutable Default Arguments]]></title>
            <link>https://dollardhingra.medium.com/1-python-anti-pattern-mutable-default-arguments-469f5822df97?source=rss-f9fdbac0bae6------2</link>
            <guid isPermaLink="false">https://medium.com/p/469f5822df97</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[python3]]></category>
            <dc:creator><![CDATA[Dollar Dhingra]]></dc:creator>
            <pubDate>Thu, 28 Oct 2021 18:30:00 GMT</pubDate>
            <atom:updated>2022-01-20T16:39:10.245Z</atom:updated>
            <content:encoded><![CDATA[<h3>#1 Python Anti-Pattern — Mutable Default Arguments</h3><h3>Introduction</h3><p>If you are not sure what a mutable default argument is, please read the full article as it can save you hours of debugging.</p><h3>Code Example With A Mutable Default Argument</h3><p>Consider the following code example below.</p><pre>def add_fruit(fruit, box=[]):<br>    box.append(fruit)<br>    return box</pre><p>Let’s understand step by step what is happening:</p><ul><li>We are creating a function to add fruits(str) in a box(list)</li><li>There is a add_fruit function which is responsible for adding the fruit</li><li>This function takes 2 arguments: fruit and box</li><li><strong>Attention!</strong>: The second argument here is a mutable default argument.</li></ul><h3>So, what is a mutable default argument?</h3><p>An argument in a function with default value as mutable. In short, Python has both mutable and immutable types. The difference being:</p><ul><li>mutables can be modified</li><li>immutables can’t be modified.</li></ul><p>For eg: Tuple is an immutable type. If we define a tuple like this:</p><pre>weekends = (&#39;saturday&#39;, &#39;sunday&#39;,)<br><br>weekends[0] = &#39;Monday&#39; # TypeError: &#39;tuple&#39; object does not support item assignment</pre><p>An immutable type can never be modified.</p><h3>What You Might Expect</h3><p>let’s modify our code and create a couple of boxes, i.e. red box and yellow box</p><pre>def add_fruit(fruit, box=[]):<br>    box.append(fruit)<br>    return box<br><br>red_box = add_fruit(&quot;apple&quot;)<br>print(f&quot;red box: {red_box}&quot;)<br><br>yellow_box = add_fruit(&quot;mango&quot;)<br>print(f&quot;yellow box: {yellow_box}&quot;)</pre><h3>Expected Output</h3><pre>red box: [&quot;apple&quot;]<br><br>yellow box: [&quot;mango&quot;]</pre><h3>Actually Output</h3><pre>red box: [&quot;apple&quot;]<br><br>yellow box: [&quot;apple&quot;, &quot;mango&quot;]</pre><p>Actually, you get the following output:</p><p>Wait? What? We never added apple in the yellow box.</p><h3>What Exactly Happened</h3><p>A new list is created once the function is defined, and the same list is used in each successive call.</p><blockquote><em>Python’s default arguments are evaluated once when the function is defined. This means that if you use a mutable default argument and mutate it, you will and have mutated that object for all future calls to the function as well.</em></blockquote><p>We will get the same result for other mutable types also(For eg: dict).</p><h3>What Should Be Done</h3><pre>def add_fruit(fruit, box=None):<br>    if box is None:<br>        box = []<br>        <br>    box.append(fruit)<br>    return box<br><br>red_box = add_fruit(&quot;apple&quot;)<br>print(f&quot;red box: {red_box}&quot;)<br><br>yellow_box = add_fruit(&quot;mango&quot;)<br>print(f&quot;yellow box: {yellow_box}&quot;)</pre><p>If your function needs to have a default argument for a mutable type, then default it with None and also add a check for the same. Let’s modify our add_fruit function:</p><p>This extra check can save hours of debugging!</p><h3>Conclusion</h3><p>It’s always a best practice to not use mutable default arguments. Instead, try adding an extra comparison check with None to handle default arguments that are mutable.</p><p><em>Originally published at </em><a href="https://dollardhingra.com/blog/python-mutable-default-arguments/"><em>https://dollardhingra.com</em></a><em> on October 28, 2021.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=469f5822df97" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple CoWIN Vaccine Availability Website]]></title>
            <link>https://dollardhingra.medium.com/simple-cowin-vaccine-availability-36be584803d5?source=rss-f9fdbac0bae6------2</link>
            <guid isPermaLink="false">https://medium.com/p/36be584803d5</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[vaccines]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[covid19]]></category>
            <category><![CDATA[cowin]]></category>
            <dc:creator><![CDATA[Dollar Dhingra]]></dc:creator>
            <pubDate>Sun, 16 May 2021 18:30:00 GMT</pubDate>
            <atom:updated>2021-06-01T12:21:55.229Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IX35e2GWGAtjz0YEyx64Ig.png" /><figcaption>Preview of App</figcaption></figure><p>Live demo: <a href="https://dollardhingra.com/cowinquick/">here</a>.</p><p><a href="https://www.youtube.com/watch?v=knjqHZNs7LM">https://www.youtube.com/watch?v=knjqHZNs7LM</a></p><p><a href="https://www.cowin.gov.in/home">CoWIN</a> is a vaccination booking platform for booking vaccination for Indian citizens. This is the largest vaccination drive ever. Anyone can simply go and book the vaccination slots as per the availability in the respective state and districts. In this post, I have created another platform just for checking vaccine availability.</p><blockquote><em>But what’s the need for creating a different platform for checking the availability when you already have the official platform?</em></blockquote><p>I had a hard time finding the vaccination slots (for the 18–45 age group). Some of the problems I(and other people I think) faced:</p><ul><li>Most of the times the slots were not available and when they were available, they were booked in seconds.</li><li>The User experience of the original CoWIN portal is not that great. Firstly you need to log in through your phone number(by an OTP which sometimes refuses to arrive on your phone). You are automatically logged out after 15–20 mins.</li><li>Some features are missing but can help find the slots. For eg: The ability to search across multiple districts.</li><li>A filter for hiding the unavailable slots from the search result would have been really helpful.</li></ul><blockquote><em>Some people have also written scripts for notifying whenever the slots are available. The idea is great but there are a couple of problems with the script’s approach: As soon as you get the notification that slots are available in your district, you open up your browser -&gt;login into the </em><a href="https://www.cowin.gov.in/home"><em>CoWIN portal</em></a><em> -&gt; select the beneficiaries that you want to get vaccinated -&gt; select the state &amp; district/enter pin code and click search -&gt; BOOM! the slots have already been booked!</em></blockquote><p>I created a simple HTML page that calls the public CoWIN API in JS. Check out the live demo <a href="https://dollardhingra.com/cowinquick/">here</a>.<br><strong>Note:</strong> This website can only be used for checking the available slots. For booking, the <a href="https://www.cowin.gov.in/home">official site</a> must be used.</p><p>This helps in booking as</p><ul><li>There is no need for entering phone number/OTP again and again</li><li>The results are visible for multiple districts at once.</li></ul><p>I have booked more than 20 slots(for friends and family) with the following approach:</p><ul><li>There is usually a 1–2 hour window when the slots are open. Usually between 6–10 pm on weekdays and 12–4 pm on weekends. These timings may change so keep casually looking for the slots whenever you have your phone in hand through the <a href="https://dollardhingra.com/cowinquick/">cowinquick site</a>.</li><li>Let’s say that you find available slots in your district or a nearby district. Note the name of the centre. Let’s say that the name of the centre is “BLK Hospital Site 1”.</li><li>In one tab, login into the <a href="https://www.cowin.gov.in/home">cowin portal</a> and select the city and district/pin code. In the other tab, you can open the <a href="https://dollardhingra.com/cowinquick/">cowinquick site</a>.</li><li>Now check if “BLK Hospital Site 1” is available. If not, then come back to the <a href="https://dollardhingra.com/cowinquick/">cowinquick site</a> and search again. There is a high probability that “BLK Hospital Site 2” will come up next in few minutes.</li><li>Keep searching after every 5–10 seconds. There is a chance that you are searching in the time window where the slots are being updated. You will come to know that the slots are being updated if you keep searching for 5–10 mins(clicking search after every 10–20 seconds). Either of the following will happen:</li><li>You will see that for some centres the slots are being open and booked in 15–20 seconds. Try booking that centre in those 15 seconds. The advantage you have on <a href="https://dollardhingra.com/cowinquick/">cowinquick site</a> is that you can see the results for multiple districts at once &amp; you don’t need to select 18+ again on every search.</li><li>There may be a situation when you don’t see any centres updating slots. You can then try the same after some time.</li></ul><p>Currently, the JS code is written by me. I also copied the code from different JS snippets. There is a need for refactoring needed by some good JS developer(I don’t know JS!! I am a python dev). Also, I have opened some issues(enhancements) in the GitHub repo on which work can be done.</p><blockquote><em>If you are passionate about open source contribution then please free to contribute! I will include your name in the list of contributors. The code can be found </em><a href="https://github.com/dollardhingra/cowinquick"><em>here</em></a></blockquote><p><em>Originally published at </em><a href="https://dollardhingra.com/blog/cowinquick-vaccine-availability/"><em>https://dollardhingra.com</em></a><em> on May 16, 2021.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36be584803d5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beginner’s guide to Abstract Base Class in Python]]></title>
            <link>https://medium.com/analytics-vidhya/beginners-guide-to-abstract-base-class-in-python-d256e535016f?source=rss-f9fdbac0bae6------2</link>
            <guid isPermaLink="false">https://medium.com/p/d256e535016f</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[oops-concepts]]></category>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[oop]]></category>
            <dc:creator><![CDATA[Dollar Dhingra]]></dc:creator>
            <pubDate>Wed, 24 Mar 2021 18:30:00 GMT</pubDate>
            <atom:updated>2021-06-11T16:14:37.159Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yEuDdYaF8jq8Ncjc.png" /></figure><h3>Introduction</h3><p>In this article, you will learn about the benefits of abstract base classes in Python and how to use them with Python’s built in abc module</p><h3>What is an abstract base class?</h3><p>In simple words, an abstract base class provides a blueprint for other classes. Abstract base classes don’t contain the implementation. Instead, they provide an interface and make sure that the derived classes are properly implemented.</p><h3>Why do we need abstract base classes?</h3><p>Imagine that you are creating a game in which you have different animals. For defining animals you can have an base class called Animal. A Dog/Cat/Duck are all the classes that are derived from the base class Animal.</p><h3>Animal Base Class</h3><pre>class Animal:<br>    def get_age():<br>        ## return age of the animal<br>    <br>    def is_dead():<br>        ## return the colour of the animal</pre><ul><li>Every animal will have both of these methods. So, we want every animal to implement these methods whenever we are inheriting an animal(Dog/Cat etc) class from the Animal class. We cannot have an animal that doesn&#39;t support any of these methods. [Rule 1]</li><li>Whenever we see an animal, we call it a dog/cat/duck/tiger. These are all kinds of <strong>animals</strong>. That is, you never look at something purple and furry and say “that is an animal and there is a no more specific way of defining it”. The point is, that you can never see an animal walking around that isn’t more specifically something else (duck, pig, etc.) [Rule 2]</li></ul><h3>Rules</h3><p>By using these 2 rules we can make our code more maintainable and programmer-friendly</p><h3>Rule 1</h3><p>Subclasses inherited from a specific base class must implement all the methods and properties defined in the abstract base class.</p><h3>Rule 2</h3><p>Abstract base classes cannot be instantiated. They are inherited by the other subclasses.</p><h3>Implementation in Python</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3492895789bff7c1592aa5c29f730112/href">https://medium.com/media/3492895789bff7c1592aa5c29f730112/href</a></iframe><p>Let’s try to implement these animal classes in Python with the rules we talked about.</p><p>In the above program, we are creating a Dog class that is inheriting all the methods from the Animal class. Let&#39;s see if rule 1 is followed. To Recap:</p><p><strong>Rule 1: Subclasses inherited from a specific base class must implement all the methods and properties defined in the abstract base class.</strong></p><p>Let’s create an object of the Dog class</p><pre>bulldog = Dog()<br><br>bulldog.get_age() # 5 years<br><br>bulldog.is_dead() # NotImplementedError</pre><p>The subclass Dog does not implement the is_dead method of the Animal base class and when we try to call this method from the bulldog object we get an exception. So this works as expected. <strong>But we can run the program successfully if we don&#39;t call this method without even a warning for breaking this rule</strong>. Ideally, all the methods of the base class should be implemented by the subclass.</p><p><strong>The above program does not follow Rule 1.</strong></p><p><strong>Rule 2: Abstract base classes cannot be instantiated. They are inherited by the other subclasses. Let’s check if Rule 2 is followed.</strong></p><p>Let’s try to instantiate the base class.</p><pre>animal = Animal()<br>animal.get_age() # NotImplementedError</pre><p>We get the error if we try to call the base class’ method. But, we can instantiate the base class. <strong>So, the above program doesn’t follow Rule 2</strong></p><h3>abc module to the rescue</h3><p>With Python’s abc module, we can do better and make sure that both the rules are followed. Let&#39;s update the above program</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/013ed629e6e23766dd6e22d48b2ddaa0/href">https://medium.com/media/013ed629e6e23766dd6e22d48b2ddaa0/href</a></iframe><p>In the above program, we have imported the helper class ABC from the module abc through which we have implemented the base class. Also, we have used the decorator @abstractmethod for all the methods in our base class.</p><p>Let’s try to instantiate our subclass: Dog</p><pre>bulldog = Dog()</pre><pre>TypeError: Can&#39;t instantiate abstract class Dog with abstract methods is_dead</pre><p>This time we get a TypeError specifying that the abstract method is not implemented.</p><p><strong>This follows Rule 1 successfully.</strong></p><p>Let’s try to instantiate our base class: Animal</p><pre>animal = Animal()</pre><pre>TypeError: Can&#39;t instantiate abstract class Animal with abstract methods get_age, is_dead</pre><p>This time we get a TypeError specifying that the abstract class cannot be instantiated.</p><p><strong>This follows Rule 2 successfully.</strong></p><h3>Conclusion</h3><p>Using ABCs in your code will make your class hierarchies more robust and more readily maintainable. Some of the key takeaways in this article are:</p><ul><li>Abstract e Classes(ABCs) ensure that derived classes implement the particular methods from the base class at instantiation time.</li><li>Using ABCs can help in writing bug-free class hierarchies which are easy to read and maintain.</li></ul><p><em>Originally published at </em><a href="https://dollardhingra.com/blog/python-abstract-base-class/"><em>https://dollardhingra.com</em></a><em> on March 24, 2021.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d256e535016f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/beginners-guide-to-abstract-base-class-in-python-d256e535016f">Beginner’s guide to Abstract Base Class in Python</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>