Urgent.News

What's breaking now, across thousands of outlets.

Tech

I read my own code from two years ago, here's what embarrassed me

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. Here's what actually embarrassed me, in the order I found it. The function that did five…

Last week, the author needed to extract a small utility from an old project they had worked on during their first side product attempt. Upon opening the repository, they spent two hours reading their own code as if it belonged to someone else, and found several instances that embarrassed them. The author presents these embarrassing moments in the order they were found.

First, they discovered a function called `validateUser` that performed multiple tasks - validating the user, hitting the database twice, sending an email, writing a log entry, and silently mutating an object passed in from three layers up. None of these actions were mentioned in the function name or comments, as past self believed comments were for others.

Next, they came across a convoluted `processOrder` function with twelve arguments, no types, and no clear naming conventions. The author struggled to understand the purpose of `flag1` and `flag2`, having to open multiple call sites to decipher their usage. They attributed this to the function's gradual accumulation of features, each added to handle a specific edge case.

The author then encountered a stale comment `// only runs once` alongside a line `setInterval(checkStatus, 5000)`, which ran every five seconds indefinitely. They questioned whether this comment was initially a false hope or a true statement that remained unchanged despite code modifications. Lastly, they found an empty catch block that silently swallowed errors without logging or rethrowing, erasing any evidence of failed database saves during its operation in production.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Building a Repeatable Audio-Extraction Workflow for Engineering Teams

Every team that ships recorded material — talk recordings, conference talks, product walkthroughs, all-hands updates — eventually hits the same operational question: where do the audio assets actually…

  • Engineering teams struggle with audio asset management.
  • Integrating extraction into processes is complex challenge.
  • Article explores production constraints and pipeline.

Why Your Loading Spinner Flickers, and the Two Rules That Fix It

Every Flutter app has this somewhere: bool _loading = false ; Future < void > _signIn () async { setState (() = > _loading = true ); try { await api .

  • Flickering spinner caused by API call timing, not design
  • 90ms API call equates to ~5.5 frames at 60fps
  • Flicker worsens near 100ms threshold

Getting Started with Excel for Data Analytics: From Basics to Data Cleaning.

Introduction Excel is a useful tool for working with data, but before any analysis can begin, the data needs to be in a usable state.

  • Excel is essential for data handling but requires data preparation before analysis
  • Clean data by removing duplicates, blank cells, and inconsistent entries
  • Use Excel tools like Pivot Tables, filters, and charts for effective analysis

More from Wednesday 2 September →