Diving Into Frontend Hell: A Software Engineer’s First Task at the New Company
Freshly out of my old company and into a better-paying one, my first task was… well, a doozy. I had the luxury of only doing half-days for the first month, which gave me just enough time to slowly descend into the chaos. And the chaos? A frontend feature that could only be described as absolute unit material—some components pushing 700, 800, even 900 lines.
Looking at the rest of the system, things looked relatively sane. Which led me to the inevitable conclusion: I had stumbled upon the granddaddy page, the Adam of this system, the origin story of all things table-and-filter-related, the Genesis. And my task was to make it cleaner, faster, and slightly less terrifying.
First things first: shoutout to the original author. Thank you for building this—without it, I wouldn’t have a chance to exercise my dark humor muscles or my refactor skills.
The Horror Show
1.) Components were doing everything: UI layout, filter state, dirty checking, search transitions, even persistence for saved views.
2.) Some of the “dirty checks” were written using JSON.stringify(currentFilters) !== JSON.stringify(baselineFilters) on every render. The CPU was not amused.
3.) And then came the classic npm run type-check or yarn run type-check moment. TypeScript screamed:
TS: “This comparison appears to be unintentional because the types ‘number | null’ and ‘string’ have no overlap.”
Me: It was very intentional.
4.) Props like assigned platforms were passed five layers deep, and some state was duplicated across multiple places.
It was a lot.
The Refactor Approach
Step by step, I survived:
- Created my own v2 folder and duplicated everything first. The idea was to survive the horrors without breaking anything in production.
- Mega-components got sliced into sub-components. Filter bars, active pills, search inputs—each became a small, focused unit.
- Extracted logic into custom hooks. Dirty checks, analytics flags, save/apply behavior—all centralized, testable, and sane.
- Replaced JSON.stringify with proper equality checks. CPU rejoiced.
- Typed everything properly. No more any[] or (state: any). My IDE finally stopped screaming.
- Moved static-ish data into context. No more prop-drilling pilgrimage.
By the end of my half-days, I had refactored a decent chunk. Monday marks my first full day on the new company, and I’ll continue the cleanup full throttle.
Lessons Learned
- Some frontend code is just born big, but that doesn’t mean it can’t be tamed.
- Duplication at first is fine if it keeps production safe while you refactor.
- TypeScript is scary, but a little intentional mischief goes a long way.
- Refactoring a “granddaddy page” gives you perspective on the rest of the system—it’s actually not as bad as it looks elsewhere.
TL;DR: I inherited a massive frontend monster, made my own v2 folder to survive, refactored some sanity back in, and learned that some pages really are the Adam of the system. Next stop: full backend paradise.