Nicolas Carlo

231 Followers
52 Following
96 Posts
πŸ§‘β€πŸ’» Refactor Legacy Code. I build tools to help you do the same!
πŸ’β€β™‚οΈ I share tips & tricks to deal with Tech Debt β€’ https://understandlegacycode.com
⛑️ Legacy Code: First Aid Kithttps://understandlegacycode.com/first-aid-kit

"Refactoring at Scale" by
Maude Lemaire is now part of Understand Legacy Code bookshelf πŸŽ‰

I like how it's rooted in reality, with concrete use cases from the trenches at Slack

I wrote an overview of what I learned, so you can answer "Is this book relevant to my situation?" πŸ˜‰

It's common for legacy code to have deeply nested statements

They make code harder to read/think about (cognitive overload) πŸ˜΅β€πŸ’«

Did you know "Guard Clauses" can help you simplify these? Now you know πŸ’‚

Here's a JavaScript example πŸ‘‡

"No but really, that code IS unreadable" πŸ₯Έ

Proximity Refactoring: things that change together, should be close together

πŸ’‘ Detect change coupling between files with git and re-organize them accordingly!

Eg. moving tests next to code in a TypeScript codebase

Thinking about all these greenfield projects that never became legacy code πŸ₯²

"The goal is to construct a bounded context that always contains data we can trust as distinct from the untrusted outside world"

β€” Domain Modeling Made Functional

That's also true when dealing with Legacy Code!

In TypeScript, I like to use Zod to do so πŸ˜‰

πŸ“’ JavaScript Developers

Ever wanted to switch an object formatting from single-line to multiple lines, and vice-versa?

You can do that in VS Code with very few keystrokes!

1️⃣ Check for "Join Lines" (βŒƒ J on macOS) ⚑
2️⃣ Insert space & format code to revert

First, "many args" is a code smell that can be fixed with a refactoring move:

✨ Preserve Whole Object ✨

Instead of a ragbag of args, you have a single object with a clear name.

It works
It depends on the size of the team
It does NOT depend on the size of the codebase

It's called "Hotspots Analysis" and it's GREAT for prioritizing Tech Debt πŸ‘

By the way, Code Climate does show that…

"But where would I find the Urgency?"

Glad you asked!

Adam Tornhill wrote amazing books to show everything version control can give you ✨

From git you can tell what parts of the codebases are *actually* worked on. Put that "Churn" on a graph with Complexity, and voilΓ !