<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Code Quality on Vedant Andhale</title>
    <link>https://www.vedant.me/tags/code-quality/</link>
    <description>Recent content in Code Quality on Vedant Andhale</description>
    <image>
      <url>https://www.vedant.me/</url>
      <link>https://www.vedant.me/</link>
    </image>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Thu, 10 Sep 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://www.vedant.me/tags/code-quality/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Names should carry the missing context</title>
      <link>https://www.vedant.me/notebook/on-naming-things/</link>
      <pubDate>Thu, 10 Sep 2026 00:00:00 +0000</pubDate>
      
      <guid>https://www.vedant.me/notebook/on-naming-things/</guid>
      <description>Units, state and domain meaning make names useful; extra syllables alone do not.</description>
      <content:encoded><![CDATA[<p><code>timeout = 30</code> leaves an important question unanswered. Thirty milliseconds or thirty seconds? A comment can explain it, but <code>timeout_seconds</code> carries the answer wherever the value is used.</p>
<p>The useful part of a name is the context it saves the reader from reconstructing.</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="c1"># These values have different meanings.</span>
</span></span><span class="line"><span class="cl"><span class="n">estimated_delivery_days</span> <span class="o">=</span> <span class="mi">4</span>
</span></span><span class="line"><span class="cl"><span class="n">scheduled_delivery_days</span> <span class="o">=</span> <span class="mi">2</span>
</span></span><span class="line"><span class="cl"><span class="n">delay_days</span> <span class="o">=</span> <span class="n">estimated_delivery_days</span> <span class="o">-</span> <span class="n">scheduled_delivery_days</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>Calling all three values variations of <code>delivery</code> would hide the relationship. Naming the unit and the kind of value makes the subtraction readable without opening another file.</p>
<h2 id="distinguish-a-fact-from-an-estimate">Distinguish a fact from an estimate</h2>
<p>This matters especially around model outputs and business calculations. <code>savings</code> can sound like money already saved. <code>estimated_savings</code> leaves room for the assumptions behind the number. <code>model_confidence</code> should not silently become <code>accuracy</code> when it reaches the interface.</p>
<p>The same care helps with state. A job can be accepted, queued, running or completed. A boolean named <code>done</code> often compresses several of those states and leaves failure behaviour unclear.</p>
<h2 id="match-the-scope">Match the scope</h2>
<p>A short local name can be perfectly clear inside a three-line loop. A public function parameter needs more context because callers see it without the implementation beside it.</p>
<p>Renaming is also a chance to notice a confused abstraction. If a helper needs a name such as <code>validate_and_save_and_maybe_notify</code>, perhaps the problem is the number of responsibilities, not your vocabulary.</p>
<p>I would rather use a slightly longer name with a precise meaning than a polished domain term that nobody on the team uses. The goal is for the next reader to make the right prediction about the code before running it.</p>
]]></content:encoded>
    </item>
    
  </channel>
</rss>
