<?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 Chinmay Apte on Medium]]></title>
        <description><![CDATA[Stories by Chinmay Apte on Medium]]></description>
        <link>https://medium.com/@chinmayapte?source=rss-ace99e441b45------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*NB76uwPPSysSk7sP.</url>
            <title>Stories by Chinmay Apte on Medium</title>
            <link>https://medium.com/@chinmayapte?source=rss-ace99e441b45------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 10:37:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@chinmayapte/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[Optimistic Boolean Functions]]></title>
            <link>https://medium.com/@chinmayapte/optimistic-boolean-functions-cffc3fa18b98?source=rss-ace99e441b45------2</link>
            <guid isPermaLink="false">https://medium.com/p/cffc3fa18b98</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[information-technology]]></category>
            <dc:creator><![CDATA[Chinmay Apte]]></dc:creator>
            <pubDate>Fri, 02 Feb 2018 07:50:17 GMT</pubDate>
            <atom:updated>2018-02-02T07:50:17.219Z</atom:updated>
            <content:encoded><![CDATA[<p>Every developer encounters situations on a day to day basis where he has to write a code that flows based on some condition, and every condition eventually resolves to a Boolean. When conditions become complex enough to be part of flow control constructs like ifs..whiles..whens we tend to extract them into a method with meaningful name which usually takes the form of isXYZ() where XYZ is the most logical name for the condition.</p><p>When I as a developer come across a method, that looks like isXYZ() I intuitively assume that this method returns true if XYZ is true. Here XYZ should come as close to business as possible, examples being isAccountActive(), isTokenValid(), isUserEligible().</p><p>One more way of writing these functions is to return true when XYZ is false, which results in something like this : isNotXYZ(), examples of such functions would be: isAccountInactive(), isTokenInvalid() or isUserInEligible(). If we think about it, these methods could easily replace any isXYZ method, for example an If block that tests isUserEligible can easily accommodate isUserInEligible with a simple negation operator.</p><p>One can simply assume this is a harmless change(while it really is harmless, if we talk about code performance and correctness). But if we think about extensibility and reuse, imagine a case where I want to use isUserInEligible in a situation where I want to execute a block of code only if user is eligible, I would end up writing something like this:</p><p>!isUserInEligible()</p><p>Whaaaaat??? Negation of Negation??</p><p>While this is equally correct, it is for me(and for a few other devs), subjectively much harder to read. More often than not, boolean conditions are a credible source of introducing a bug, and I would rather opt for a readable method name than get confused over silly conditions.</p><blockquote><em>So, in conclusion, Boolean methods should look on the positive side of life — should have names that express if some condition is true, rather than expressing if some condition is ‘not’ true. In short the Boolean methods must be Optimistic.</em></blockquote><p>– Chinmay<br><a href="https://geeknarrator.com/">https://geeknarrator.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cffc3fa18b98" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>