<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ethan Wells</title>
    <description>The latest articles on DEV Community by Ethan Wells (@ethanpkg).</description>
    <link>https://dev.to/ethanpkg</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4106718%2F34a41524-9c2b-46d4-9e01-ec3de0176aba.jpg</url>
      <title>DEV Community: Ethan Wells</title>
      <link>https://dev.to/ethanpkg</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ethanpkg"/>
    <language>en</language>
    <item>
      <title>I read my own code from two years ago, here's what embarrassed me</title>
      <dc:creator>Ethan Wells</dc:creator>
      <pubDate>Wed, 02 Sep 2026 19:11:51 +0000</pubDate>
      <link>https://dev.to/ethanpkg/i-read-my-own-code-from-two-years-ago-heres-what-embarrassed-me-51oa</link>
      <guid>https://dev.to/ethanpkg/i-read-my-own-code-from-two-years-ago-heres-what-embarrassed-me-51oa</guid>
      <description>&lt;p&gt;Last week I needed to pull a small utility out of an old project, something I built during my first real attempt at a side product. I opened the repo expecting a quick copy paste job. Instead I spent two hours reading my own code from two years ago like it belonged to a stranger, and honestly, some of it did.&lt;/p&gt;

&lt;p&gt;Here's what actually embarrassed me, in the order I found it.&lt;/p&gt;

&lt;h3&gt;
  
  
  The function that did five things and was named after one of them
&lt;/h3&gt;

&lt;p&gt;I found a function called &lt;code&gt;validateUser&lt;/code&gt;. It validated the user. It also hit the database twice, sent an email, wrote a log entry and, somewhere in the middle, quietly mutated an object that got passed in from three layers up. None of that showed up in the name. None of it showed up in a comment either, because past me apparently believed comments were for other people.&lt;/p&gt;

&lt;p&gt;I remember writing this function. I remember feeling clever about it, because it "handled everything in one place." Two years later, one place turned out to mean one place I had to hold my breath before touching.&lt;/p&gt;

&lt;h3&gt;
  
  
  Twelve arguments, no types, good luck
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;processOrder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;discount&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;shipping&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;tax&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;notes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;flag1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;flag2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;source&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;retry&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I did not remember what &lt;code&gt;flag1&lt;/code&gt; and &lt;code&gt;flag2&lt;/code&gt; meant. I opened three call sites before I found one that used both, and even then I had to guess from context which was which. This was JavaScript with no TypeScript, no JSDoc, nothing. Past me trusted future me to just know. Future me did not know.&lt;/p&gt;

&lt;p&gt;The worst part is I can reconstruct exactly why this happened. Each argument got added one at a time, over weeks, every time a new edge case showed up. Nobody sat down and designed this function. It accreted, the way a lot of bad code does, one reasonable decision at a time until the sum stopped being reasonable.&lt;/p&gt;

&lt;h3&gt;
  
  
  A comment that lied
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// only runs once&lt;/span&gt;
&lt;span class="nf"&gt;setInterval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;checkStatus&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I stared at this for a solid minute. It was not once. It ran every five seconds, forever, and the comment was either wishful thinking from the start or true at some earlier point and never updated when the code changed underneath it. I have no way to know which, and that's the actual lesson here. A comment that goes stale is worse than no comment, because it actively lies to whoever reads it next, and the next reader was me.&lt;/p&gt;

&lt;h3&gt;
  
  
  Error handling that just made errors disappear
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;saveToDatabase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;record&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An empty catch block. Silent, total, no logging, no rethrow, nothing. I have genuinely no idea how many records failed to save during whatever period this ran in production. There is no way to find out now. Past me made a decision that erased its own evidence.&lt;/p&gt;

&lt;p&gt;I think I wrote this because something was throwing an error I didn't understand at the time, and the empty catch made the error go away, which felt like fixing it. It was not fixing it. It was hiding it somewhere I would never think to look again.&lt;/p&gt;

&lt;h3&gt;
  
  
  Variable names that told me nothing
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;data&lt;/code&gt;, &lt;code&gt;data2&lt;/code&gt;, &lt;code&gt;tempData&lt;/code&gt;, &lt;code&gt;finalData&lt;/code&gt;. Four variables, one function, and not one name that told me what any of them actually held. I had to trace the assignments line by line to figure out that &lt;code&gt;data2&lt;/code&gt; was the filtered version of &lt;code&gt;data&lt;/code&gt;, and &lt;code&gt;finalData&lt;/code&gt; was &lt;code&gt;data2&lt;/code&gt; after a sort I didn't understand the reason for.&lt;/p&gt;

&lt;p&gt;I know why this happens in the moment. You're deep in a problem, the logic is fully loaded in your head, and naming things well feels like a tax on your focus. The math only stops working out once you leave the code and come back later without that context loaded anymore, which is exactly what happened here.&lt;/p&gt;

&lt;h3&gt;
  
  
  What actually surprised me
&lt;/h3&gt;

&lt;p&gt;I expected to find bad code. What actually surprised me was how confident all of it looked. No hedging comments, no TODOs admitting a shortcut, nothing that signaled "I know this is rough." Past me wrote every one of these decisions like it was obviously correct. That confidence is what makes old code dangerous to read, because nothing in the code itself warns you where the landmines are.&lt;/p&gt;

&lt;p&gt;I also noticed I've fixed most of these specific habits since then, not because I read a blog post about clean code, but because I got burned by each one individually, in production, at a bad time. The empty catch block cost me a debugging session I still remember. The twelve argument function cost me an afternoon just last week. Apparently that's how I actually learn things. Not from advice, from consequences.&lt;/p&gt;

&lt;h3&gt;
  
  
  What I'm doing differently now
&lt;/h3&gt;

&lt;p&gt;Nothing dramatic. I write smaller functions, mostly because I got tired of scrolling. I never leave a catch block empty, even if all it does is log and rethrow. I stopped naming things &lt;code&gt;data2&lt;/code&gt;. None of this required a framework or a philosophy, just enough scar tissue to remember the pain the next time I was tempted to take the shortcut.&lt;/p&gt;

&lt;p&gt;I'll probably read this exact code again in another two years and find something in what I'm writing right now that makes me wince. That's fine. If it didn't, it would mean I'd stopped getting better, and an embarrassing function beats a stalled one every time.&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>programming</category>
      <category>career</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
