<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Code Quality</title>
    <link>https://pulpme.sh/~sample10</link>
    <description>The practice of reading and reviewing other people&#39;s work</description>
    <language>en</language>
    <atom:link href="https://pulpme.sh/~sample10/rss.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>When to refactor</title>
      <link>https://pulpme.sh/~sample10/when-to-refactor.html</link>
      <guid isPermaLink="true">https://pulpme.sh/~sample10/when-to-refactor.html</guid>
      <pubDate>Sun, 17 May 2026 00:00:00 +0000</pubDate>
      <category>refactoring</category>
      <category>improvement</category>
      <category>judgement</category>
      <description><![CDATA[
<p>Refactoring is improvement without change to behavior. The moment it changes<br />
behavior, it stopped being refactoring and became a rewrite.</p>

<h2 id="the-code-that-should-stay">The code that should stay</h2>

<p>Code that:</p>
<ul>
  <li>Works</li>
  <li>Has tests</li>
  <li>Nobody complains about</li>
  <li>Is not on the critical path</li>
</ul>

<p>Leave it. A refactor is not free—it is a bet that the improvement is worth the<br />
risk.</p>

<h2 id="the-code-that-needs-refactoring">The code that needs refactoring</h2>

<p>Code that:</p>
<ul>
  <li>Works but is hard to change</li>
  <li>Has been changed three times already</li>
  <li>Everyone dreads touching</li>
</ul>

<p>This code is expensive. Every change costs more than it should. Refactoring<br />
pays for itself in the next change.</p>

<h2 id="the-refactor-that-goes-wrong">The refactor that goes wrong</h2>

<p>A function that is confusing, so you refactor it to be clear. In the process,<br />
you change the logic slightly. The tests still pass because the tests were<br />
written to test the function, not to test the behavior.</p>

<p>The refactor changed the behavior and the tests did not catch it.</p>

<h2 id="the-safe-refactor">The safe refactor</h2>

<p>Tests first. Run them. Change the code. Run them again. If they pass, the<br />
behavior did not change.</p>

<p>If the tests do not pass, the refactor changed something and the change is<br />
detected.</p>

<h2 id="what-i-learned-the-hard-way">What I learned the hard way</h2>

<p>A refactor without tests is not a refactor, it is a rewrite. Rewrites introduce<br />
bugs. Refactors do not.</p>

<h2 id="the-question-that-matters">The question that matters</h2>

<p>“Will this refactor make the next change easier?” If yes, do it. If no, the<br />
code is fine the way it is.</p>

<p>The code that is hard to read but easy to change is better code than the code<br />
that is nice to read but hard to change.</p>

<p><strong>The purpose of refactoring is not beauty. It is to make future changes<br />
cheaper. If there will be no future changes, there is nothing to refactor.</strong></p>
]]></description>
    </item>
    <item>
      <title>Tests are not enough</title>
      <link>https://pulpme.sh/~sample10/tests-are-not-enough.html</link>
      <guid isPermaLink="true">https://pulpme.sh/~sample10/tests-are-not-enough.html</guid>
      <pubDate>Tue, 14 Apr 2026 00:00:00 +0000</pubDate>
      <category>testing</category>
      <category>review</category>
      <category>coverage</category>
      <description><![CDATA[
<p>A comprehensive test suite confirms that the code does what you told it to do.<br />
A human review confirms that what you told it to do is what you actually want.</p>

<h2 id="the-test-that-passes-but-the-code-is-wrong">The test that passes but the code is wrong</h2>

<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">def</span> <span class="nf">eligible_for_discount?</span><span class="p">(</span>purchase_amount<span class="p">)</span>
  purchase_amount <span class="o">&gt;</span> <span class="mi">100</span>
<span class="k">end</span>
</code></pre></div></div>

<p>Test:</p>
<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code>assert eligible_for_discount?<span class="p">(</span><span class="mi">101</span><span class="p">)</span>
assert <span class="o">!</span>eligible_for_discount?<span class="p">(</span><span class="mi">100</span><span class="p">)</span>
assert <span class="o">!</span>eligible_for_discount?<span class="p">(</span><span class="mi">99</span><span class="p">)</span>
</code></pre></div></div>

<p>All pass. The code is wrong. The rule is “greater than or equal to 100” not<br />
“greater than 100.”</p>

<p>The test writer and the code writer made the same mistake. The test<br />
confirmed the mistake.</p>

<h2 id="what-a-review-finds">What a review finds</h2>

<p>A human reading the code asks: “What if the amount is exactly 100?” and finds<br />
the boundary is wrong.</p>

<h2 id="the-logic-that-is-technically-correct-but-practically-wrong">The logic that is technically correct but practically wrong</h2>

<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">def</span> <span class="nf">refund_request_days_remaining</span><span class="p">(</span>purchase_date<span class="p">)</span>
  days_since <span class="o">=</span> <span class="p">(</span><span class="no">Date</span><span class="p">.</span>today <span class="o">-</span> purchase_date<span class="p">).</span>to_i
  <span class="mi">30</span> <span class="o">-</span> days_since
<span class="k">end</span>
</code></pre></div></div>

<p>The test passes. The code is correct. But if a customer bought on day 0, they<br />
have 30 days. If they bought on day 1, they have 29 days. If they bought on day<br />
30, they have 0 days.</p>

<p>The business rule is probably “within 30 days of purchase,” which means day 30<br />
should have 1 day remaining, not 0.</p>

<p>A test can confirm the calculation. Only a human can catch the off-by-one<br />
business logic.</p>

<h2 id="the-performance-that-is-not-tested">The performance that is not tested</h2>

<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">def</span> <span class="nf">find_active_users</span>
  <span class="no">User</span><span class="p">.</span>all<span class="p">.</span>select <span class="p">{</span> <span class="o">|</span>u<span class="o">|</span> u<span class="p">.</span>active? <span class="p">}</span>
<span class="k">end</span>
</code></pre></div></div>

<p>The test passes. The code is correct. With 100 users the query is fast. With<br />
100,000 users it is a DOS attack waiting to happen.</p>

<p>A test cannot measure intent. A human can ask: “What happens when this table<br />
grows?”</p>

<h2 id="why-this-matters">Why this matters</h2>

<p>Tests confirm the implementation. Reviews confirm the intention.</p>

<p>A reviewed test suite is one where the code does what you meant and does it<br />
efficiently.</p>

<p>An untested review is one where clever code breaks in production. A tested<br />
review is one where clever code fails fast and obviously.</p>

<p><strong>The review that asks “Is this right?” catches the bug. The test that asks<br />
“Does this work?” catches the typo. Both are needed.</strong></p>
]]></description>
    </item>
    <item>
      <title>The review that teaches</title>
      <link>https://pulpme.sh/~sample10/the-review-that-teaches.html</link>
      <guid isPermaLink="true">https://pulpme.sh/~sample10/the-review-that-teaches.html</guid>
      <pubDate>Sun, 22 Mar 2026 00:00:00 +0000</pubDate>
      <category>mentoring</category>
      <category>feedback</category>
      <category>growth</category>
      <description><![CDATA[
<p>A review can be a correction or a lesson. The same feedback, written differently,<br />
is either one or the other.</p>

<h2 id="the-correction">The correction</h2>

<p>“The function is too long. Split it into two functions.”</p>

<p>This is correct. It is also lazy. The author learns nothing except that the<br />
reviewer does not like long functions.</p>

<h2 id="the-lesson">The lesson</h2>

<p>“This function does three things: parse, validate, and persist. Each of these<br />
is a decision point. When the parsing fails, someone reading this wants to know<br />
whether the validation failed or the persistence failed. Right now they cannot<br />
tell. Split it into three functions so the failure point is clear.”</p>

<p>This teaches <em>why</em>. The author learns that the reason to split is not fashion,<br />
it is clarity. The next time they write a function that does multiple things,<br />
they will make the decision themselves.</p>

<h2 id="the-comment-that-changes-code">The comment that changes code</h2>

<p>“What happens if <code>user.name</code> is nil?” turns into a check, a test, a fallback,<br />
and the code is more resilient.</p>

<p>“This will crash if the user has no name” teaches <em>why</em> it is a problem.</p>

<h2 id="what-reviewers-often-do-wrong">What reviewers often do wrong</h2>

<ol>
  <li>Correct the code without explaining the reasoning</li>
  <li>Suggest a fix without explaining the trade-offs</li>
  <li>Approve code that works but will be hard to maintain</li>
  <li>Disapprove code that is a little different from how they would have written it</li>
</ol>

<h2 id="what-reviewers-should-do">What reviewers should do</h2>

<ol>
  <li>Explain the reasoning: “This pattern makes it easier to test because…”</li>
  <li>Explain the trade-off: “This is slower but it is clearer…”</li>
  <li>Ask the question: “What happens if this fails?”</li>
  <li>Differentiate: “I would have written it this way, but your way is fine too.”</li>
</ol>

<h2 id="the-review-i-am-most-proud-of">The review I am most proud of</h2>

<p>A function was correct but confusing. I wrote: “I do not understand what this<br />
function does from reading the name or the code. Can you rename the function<br />
and add a comment about the three cases you are handling?”</p>

<p>The author rewrote it in twenty minutes and asked: “Is this better?” It was. And<br />
they learned that clarity matters more than correctness.</p>

<h2 id="why-this-matters">Why this matters</h2>

<p>A junior developer reading a correction learns that they made a mistake. A junior<br />
developer reading a lesson learns how to make better decisions.</p>

<p><strong>The review that teaches is the one that stays with someone for years. The<br />
review that corrects is forgotten by tomorrow.</strong></p>
]]></description>
    </item>
    <item>
      <title>Naming is a problem</title>
      <link>https://pulpme.sh/~sample10/naming-is-a-problem.html</link>
      <guid isPermaLink="true">https://pulpme.sh/~sample10/naming-is-a-problem.html</guid>
      <pubDate>Wed, 18 Feb 2026 00:00:00 +0000</pubDate>
      <category>naming</category>
      <category>clarity</category>
      <category>intent</category>
      <description><![CDATA[
<p>Naming is harder than writing code because the name has to survive longer than<br />
the code. The function might change. The name has to explain what it does when<br />
someone reads it a year from now.</p>

<h2 id="the-name-that-lies">The name that lies</h2>

<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">def</span> <span class="nf">process</span><span class="p">(</span>data<span class="p">)</span>
  parse<span class="p">(</span>data<span class="p">)</span>
  validate<span class="p">(</span>data<span class="p">)</span>
  save<span class="p">(</span>data<span class="p">)</span>
<span class="k">end</span>
</code></pre></div></div>

<p>What does this do? No idea. <code>process</code> could mean anything. Six months from now,<br />
someone reading this will spend twenty minutes figuring out what it does.</p>

<p>Better: <code>import_and_validate_user_data</code> or <code>parse_and_persist_csv</code> or whatever<br />
it actually does.</p>

<h2 id="the-name-that-tells-a-story">The name that tells a story</h2>

<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">def</span> <span class="nf">apply_late_fee</span><span class="p">(</span>invoice<span class="p">)</span>
  invoice<span class="p">.</span>amount <span class="o">+=</span> <span class="mi">10</span>
  invoice<span class="p">.</span>save
<span class="k">end</span>
</code></pre></div></div>

<p>The name tells a story: this function applies a fee. The code confirms it: the<br />
amount increases and the change is persisted.</p>

<p>The name and the code agree, and someone reading the name knows what to expect.</p>

<h2 id="the-name-that-hides-the-cost">The name that hides the cost</h2>

<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">def</span> <span class="nf">get_user</span><span class="p">(</span>id<span class="p">)</span>
  <span class="no">User</span><span class="p">.</span>find<span class="p">(</span>id<span class="p">)</span>  <span class="c1"># database call, 50ms</span>
<span class="k">end</span>
</code></pre></div></div>

<p>The name says <code>get</code>. The reader expects a cache lookup. The code does a<br />
database call. The name is not lying but it is misleading.</p>

<p>Better: <code>fetch_user_from_database</code> or <code>load_user</code> or something that hints at<br />
the cost.</p>

<h2 id="the-rule-that-works">The rule that works</h2>

<p>A name should answer the question: “What happens if I call this?” If the name<br />
does not answer that question, the name is wrong.</p>

<h2 id="the-name-that-is-technically-right-but-still-wrong">The name that is technically right but still wrong</h2>

<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">def</span> <span class="nf">handle_response</span><span class="p">(</span>response<span class="p">)</span>
  <span class="c1"># 200 lines of logic</span>
<span class="k">end</span>
</code></pre></div></div>

<p>Technically correct. But the word <code>handle</code> is so broad that it is empty. It does<br />
not answer the question at all.</p>

<h2 id="the-names-in-every-codebase">The names in every codebase</h2>

<ul>
  <li><code>utils</code>, <code>helpers</code>, <code>common</code> — names that mean nothing</li>
  <li><code>process</code>, <code>handle</code>, <code>do_something</code> — names that tell you nothing</li>
  <li><code>temp</code>, <code>obj</code>, <code>x</code> — names that tell you the author was hurrying</li>
</ul>

<p>These names are not bad because they are short. They are bad because they do<br />
not answer the question.</p>

<h2 id="what-i-learned">What I learned</h2>

<p>Spend more time on the name than the code. A name that is right makes the code<br />
obvious. Code that is obvious is easier to maintain.</p>

<p><strong>The name that costs you five minutes to think of saves someone an hour of<br />
confusion later.</strong></p>
]]></description>
    </item>
    <item>
      <title>What a review finds</title>
      <link>https://pulpme.sh/~sample10/what-a-review-finds.html</link>
      <guid isPermaLink="true">https://pulpme.sh/~sample10/what-a-review-finds.html</guid>
      <pubDate>Tue, 20 Jan 2026 00:00:00 +0000</pubDate>
      <category>review</category>
      <category>testing</category>
      <category>quality</category>
      <description><![CDATA[
<p>A test finds whether the code does what it was supposed to do. A review finds<br />
whether the code does what it actually does.</p>

<h2 id="what-the-test-misses">What the test misses</h2>

<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">def</span> <span class="nf">charge_account</span><span class="p">(</span>amount<span class="p">)</span>
  balance <span class="o">=</span> get_balance
  <span class="k">if</span> balance <span class="o">&gt;</span> amount
    deduct<span class="p">(</span>amount<span class="p">)</span>
    log<span class="p">(</span><span class="s2">"charged"</span><span class="p">,</span> amount<span class="p">)</span>
  <span class="k">else</span>
    log<span class="p">(</span><span class="s2">"declined"</span><span class="p">,</span> amount<span class="p">)</span>
  <span class="k">end</span>
<span class="k">end</span>
</code></pre></div></div>

<p>The test passes. Balance is sufficient, charge succeeds, log is called. All<br />
green.</p>

<p>The review finds: if balance is exactly equal to amount, nothing happens. The<br />
code is written as <code>&gt;</code> not <code>&gt;=</code>. The test did not catch this because the test<br />
writer assumed the same condition as the author.</p>

<h2 id="what-a-human-finds">What a human finds</h2>

<ol>
  <li>A condition that is stricter than intended</li>
  <li>A variable name that could be clearer</li>
  <li>An assumption that might not be true in edge cases</li>
  <li>A log call in both branches that could be factored out</li>
</ol>

<p>Tests find that the code runs. Reviews find that the code makes sense.</p>

<h2 id="why-both-matter">Why both matter</h2>

<p>A tested untested code breaks. A reviewed tested code might be slow, might<br />
be wrong in a way the test does not check, might be a footgun waiting to<br />
surprise someone.</p>

<h2 id="the-test-that-misses-the-review">The test that misses the review</h2>

<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">def</span> <span class="nf">send_email</span><span class="p">(</span>address<span class="p">)</span>
  <span class="k">if</span> valid_email?<span class="p">(</span>address<span class="p">)</span>
    email_service<span class="p">.</span>send<span class="p">(</span>address<span class="p">,</span> template<span class="p">)</span>
  <span class="k">end</span>
<span class="k">end</span>
</code></pre></div></div>

<p>Tests pass for valid emails and invalid emails. The review finds: what if the<br />
email service fails? What if the template is missing? What if <code>valid_email?</code><br />
returns true for something that is not actually valid?</p>

<h2 id="the-review-that-finds-the-bug-the-test-could-not">The review that finds the bug the test could not</h2>

<p>A test cannot know what you did not test for. A review can ask the question:<br />
“What happens if this breaks?” and “Are we ready for that?”</p>

<h2 id="why-this-matters">Why this matters</h2>

<p>Code review is not about correctness. It is about <em>resilience</em>. A function that<br />
works is not a function that <em>continues</em> to work when something changes.</p>

<p><strong>The review is where you ask whether the code is ready for the future. The<br />
test is where you confirm it works today.</strong></p>
]]></description>
    </item>
  </channel>
</rss>
