Available 1-2 days/week as a fractional product engineer → Get the overview PDF
Skip to content

How I untangled and optimised a codebase without a rewrite

Posted on:Jul 2025

When I joined this project, it had grown without much architecture oversight. Typical of fast-moving startups.

Components files would regularly exceed 300 lines, and passing data down many layers became a maintenance nightmare. Every minor UI change required digging through tangled code and duplicated logic.

A full rewrite was (obviously) not an option.

Instead, I focused on targeted improvements to make the code easier to work with, faster to update and more reliable.

Core issues

Both core issues originated from anti-patterns:

  1. Data passed through too many layers: Simple state like whether a modal is open was being sent down 6+ levels of components.
  2. Big components doing too much: One file managed UI, data fetching, state, and side effects all at once, making it hard to isolate problems or reuse code.

How I fixed it

Instead of rewriting, I used React’s built-in tools to share state directly where it was needed, no more prop-drilling. This meant components could focus on what they do best: displaying UI.

I also split big components into smaller, focused pieces with clearly defined responsibilities. Logic and side effects moved into reusable “hooks,” while UI rendering was delegated to simple, stateless components.

Results

Keeping functionality stable while making change cheaper and safer, following Good Programming Principles.

Unblock, ship, or refactor, fast

Explore scoped engagements designed to ship outcomes, not hours.