<?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 Samhith K on Medium]]></title>
        <description><![CDATA[Stories by Samhith K on Medium]]></description>
        <link>https://medium.com/@codesk?source=rss-67bb7f64d084------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*boZ9pqPebJBGBgHwAR0EQA.jpeg</url>
            <title>Stories by Samhith K on Medium</title>
            <link>https://medium.com/@codesk?source=rss-67bb7f64d084------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 07:49:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@codesk/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[What’s in a Name]]></title>
            <link>https://medium.com/@codesk/whats-in-a-name-8de1d01fdd7f?source=rss-67bb7f64d084------2</link>
            <guid isPermaLink="false">https://medium.com/p/8de1d01fdd7f</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[discipline]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Samhith K]]></dc:creator>
            <pubDate>Wed, 05 Dec 2018 08:07:53 GMT</pubDate>
            <atom:updated>2018-12-05T14:35:15.200Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*cKstNvtMnv8V3C1z0Zs3Bw.jpeg" /></figure><p>Names are everywhere in software. We name our variables, we name our functions, classes, packages, arguments, source files, directories, war, jar and ear files. We name, name and name. Because we do so much of it we better do it really well.</p><p>You might be wondering what is the big deal about naming? In this post, I would like to demonstrate a simple example to highlight the importance of good naming and how it can save you from consuming huge amount of time and frustration in understanding previously written code. In the posts to follow, I will be publishing one rule at a time for creating good names.</p><p>Just give the below code a read. It is a 9 line code and must take less than a minute for us to understand it.</p><pre>public List&lt;int[]&gt; getThem(){<br>    List&lt;int[]&gt; list1 = new ArrayList&lt;int[]&gt;();<br>    for(int[] x : theList){<br>        if(x[0]==4){<br>            list1.add(x);<br>        }<br>    }<br>    return list1;<br>}</pre><p>It is hard to tell what the code is doing. We can tell what it does to the variables, but we cannot discern it’s function.</p><p>Why is it hard to tell what the code is doing? No complex expressions, not many levels of nesting, spacing and indentation are fine, the data structures used are straight forward. It is just a simple code with list and arrays. <strong><em>The problem is not with the simplicity of the code, it is with the implicity.</em></strong></p><p>To understand what that code is doing, we will need answers to the following questions:</p><ol><li>What kind of things are in theList ?</li><li>What are you trying to check in x[0]==4 ?</li><li>What is the significance of 0 ?</li><li>What is the significance of 4 ?</li><li>How would I use the item being returned ?</li></ol><p>The answers to these were not present in the code sample. But they could have been present. Say we are evaluating a list of providers to determine who lives in “Orange county” of California. So, let us rename theList with providerList . Each provider is represented by an int[] and the first field gives the location of the provider, with 4 representing the County’s serial number. So, let us assign orangeCounty=4 . Just by declaring these concepts we can improve the code considerably.</p><pre>public List&lt;int[]&gt; getOrangeCountyProviders(){<br>    List&lt;int[]&gt; orangeCountyProviders = new ArrayList&lt;int[]&gt;();<br>    for(int[] provider: providerList){<br>        if(provider[LOCATION_CODE]==orangeCounty){<br>            orangeCountyProviders.add(provider);<br>        }<br>    }<br>    return orangeCountyProviders;<br>}</pre><p>Notice that the simplicity of the code has not changed, it still has the same number of constants, operators and nesting levels. But this code makes sense. This code takes less than a minute to understand. Anyone can start working on this code in the future with ease.</p><p>Just by making simple name changes we made the code more implicit, more revealing. It is now easy to understand what’s going on. <strong>This is the power of choosing good names.</strong></p><p>Stay tuned to get more insights to creating good names.</p><p>Inspired by Robert C Martin aka Uncle Bob.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8de1d01fdd7f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>