<?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 Alan Levicki on Medium]]></title>
        <description><![CDATA[Stories by Alan Levicki on Medium]]></description>
        <link>https://medium.com/@alevicki?source=rss-3f268168eb47------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*0CgwmIuERuap3whW.</url>
            <title>Stories by Alan Levicki on Medium</title>
            <link>https://medium.com/@alevicki?source=rss-3f268168eb47------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 11:50:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alevicki/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[Brackets and Single Line Conditionals]]></title>
            <link>https://medium.com/katana-stab-studios-blog/brackets-and-single-line-conditionals-d3f8304e7567?source=rss-3f268168eb47------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3f8304e7567</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[code-style]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Alan Levicki]]></dc:creator>
            <pubDate>Wed, 10 May 2017 19:50:44 GMT</pubDate>
            <atom:updated>2017-05-12T18:36:41.729Z</atom:updated>
            <content:encoded><![CDATA[<p>I believe using single line conditionals, such as</p><pre>if (!usernameIsValid()) return false;</pre><p>as opposed to</p><pre>if (!usernameIsValid()) {<br>  return false;<br>}</pre><p>is one of those things that people have strong personal preferences about. I come down firmly on the side of always using the brackets and the extra line. I feel that it is easier to read and am not bothered by the extra lines.</p><p>I recently had a discussion with another developer where he tried to convince me that keeping it on a single line was better. Let’s examine some of his arguments for the single line conditional.</p><ul><li><strong>It saves space</strong><br>Technically this is true, but this is not a valid concern. Space in source control systems is not at a premium. A lot of code gets compiled, so the space savings is done at that step, and if you are using Javascript chances are the code is minified.</li><li><strong>It is more readable</strong><br>This is probably down to personal preference. I would argue that the brackets and multiple lines are more readable because a block is being created, so it should have indicators and when browsing code it may be easy to skip over a single line conditional.</li></ul><p>Arguments for using multiple lines</p><ul><li><strong>Consistency</strong><br>Using brackets and multiple lines for a single line conditional is consistent with how they are used for a multi-line conditionals. This means it is easier to read because it is expected</li><li><strong>Readability</strong><br>This may come down to personal preference, but I think it is easier to read the multiple line version in the midst of a larger block of code. I will grant that there may be times when the opposite may be true (although it may be that there is a better way to write that code), eg</li></ul><pre>if (form.name.isInvalid()) return false;<br>if (form.address.isInvalid()) return false;<br>if (form.zip.isInvalid()) return false;<br>if (form.state.isInvalid()) return false;<br>if (form.city.isInvalid()) return false;</pre><p>Again, I believe the choice here is mostly personal preference. I do not think that using the lines creates any large issues in a codebase. But due to the consistency and readability issues I prefer to never use single line conditionals.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3f8304e7567" width="1" height="1" alt=""><hr><p><a href="https://medium.com/katana-stab-studios-blog/brackets-and-single-line-conditionals-d3f8304e7567">Brackets and Single Line Conditionals</a> was originally published in <a href="https://medium.com/katana-stab-studios-blog">Katana Stab Studios Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>