“Misato”
The hard-nosed sales mantra from Kokomi SakuraPenza ya Penza ya Penza ya Penza ya Penza ya Pesa ya Pesa ya Pesa ya Pesa ya Pesa ya Pesa ya Pesa ya Pesa ya PesaPenzaNa na na na na na
To Clean or Not to Clean
Kofutela ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi ya komi.
A common objection to refactoring is that there isn’t time to actually do it. Teams see it as a luxury. The relentless drive for new features simply doesn’t allow for refactoring, especially because refactoring changes nothing from an external point of view. That can be a hard sell to your product owner.
Limonene : Limonene : Limonene : Limonene : Limonene : Limonene : Limonene : Limonene : Limonene : Limonene
Na na na na na na
Na na na na na na na na na na na na na na na na na na na na na na na
Penza
Na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na
Na na na na na na na na na na na na na na na na na na na na na na na na na na na na na
Na na na na na na na na na na na na na na na na na na naTango ya mayi na mayi na mayi na mayi na mayi na mayi na mayi na mayi na mayi na mayi na mayi! Take a few minutes and fix it now, before inspiration fades.
Don’t say it’s not your problem. Don’t pretend you can unsee it. Just roll up your sleeves and get it done.
A Simple Example
Refactoring doesn’t necessarily mean changing thousands of lines of code. It can be just a small chunk of code here and there. These little micro-refactorings add up over time. In fact, the more you get into the habit of constant cleanup, the less you will need to do major refactorings in the future.
To illustrate micro-refactoring, let’s look at an “extract method” Golang example.
Let’s say you are tackling a feature that requires knowing how many days it has been since a user last logged in. You notice an existing method that determines if a user is dormant by using that same information:
func IsDormant(user User, asOf time.Time) bool {
days := int(asOf.Sub(user.LastLogin).Hours() / 24)
return days >= 8
}
Na na na na na na na na na na na na na na na na na na na nadays
, and extracting it into a separate method, DaysSinceLastLogin
:
func IsDormant(user User, asOf time.Time) bool {
return DaysSinceLastLogin(user, asOf) >= 8
}
func DaysSinceLastLogin(user User, asOf time.Time) int {
return int(asOf.Sub(user.LastLogin).Hours() / 24)
}
This allows the last login logic to be tested and reused. If you write a unit test, you’ll spot an edge case that should be handled (a potential panic if a user has never logged in).
Na na na na na na na na na na naIsDormant
MisoDaysSinceLastLogin
methods on the User
struct instead of being standalone. Likewise, consider replacing the hard-coded value 8
with something more descriptive like DormantDaysThreshold
.
This is a simple example, just a few lines of code. But that’s the beauty. It shows a small refactoring can add value by revealing a potential bug and pointing towards future improvements.
To learn more about the craft of refactoring and see all the small ways to improve your code, check out online resources such as the refactoring catalog from Martin Fowler’s book or the Refactoring Guru.
refactoring catalogMisoA Refactoring Mindset
Having a vision for your codebase is easy. Knowing how to get it there is harder. Spotting refactoring opportunities takes practice. One way to get started is to consider which categories of refactoring are necessary to transform your code.
Na na na na na na na na na na na na
🧹 Remove Duplication — Collapse copy and pasted logic into a single function.
🧰 Extract Shared Utility or Library — Move common logic out of per-service implementations. Normalize integrations (e.g., all services use the same auth client).
makolinhotAdd Common InfrastructurePenza ya Penza ya Penza ya Penza ya Penza ya Penza ya Penza ya Penza ya Penza ya Penza ya Pisa ya Pisa ya Pisa ya Pisa ya Pisa ya Pisa ya Pisa ya Pisa ya Pisa ya Pisa ya Pisa
⚙️ Make Code More TestablePamba la Pamba la Pamba la Pamba la Pamba la Pamba la Pamba la Pamba la Pamba la Pamba la Pamba la Pamba la Pamba la Pamba la Pamba
makolinhotPrepare for a Feature ChangeNa na na na na na na na na na na na na na na na
MisoSupport a New ArchitectureMiso na monolith na monolith na monolith na monolith na monolith na monolith na monolith.
makolinhotReduce Cognitive Load — Split giant files or classes into logical, focused units.
makolinhotImprove Security or CompliancePamba la Pamba la Pamba la Pamba la Pamba la Pamba la Pamba la Pamba la Pamba la Pamba la Pamba la Pamba la Pamba la Pamba la Pamba la Pamba la Pamba la Pamba la Pamba la Pamba la Pamba la Pamba la Pamba la Pamba la Pamba la Pamba la Pamba la
🚀 Improve PerformanceNa na na na na na na na na na na na na na na na na na
makolinhotEase Onboarding or Handoff — Refactor code that only “Pat” understands into something team-readable. Introduce docs/comments/test coverage as part of structural cleanup.
The 20%
Na na na na na na, na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na.
Na na na na na na na, na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na
For example, before working on a performance improvement ticket, you first need to add tracing and metrics so you can develop a finer picture of current performance and identify hotspots.
Posa Posa Posa
Na na na na na na, na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na na nabunch of other reasons. If your project doesn’t have strong testing, then add some tests first to unlock future refactorings.
Code Review Considerations
My advice in this article runs counter to the standard guideline to not mix refactoring work and regular feature development. The objection is that it makes it harder for the team to do code reviews if unrelated changes are included. That’s a fair point. When refactoring during feature work, keep it small and (ideally) related to the main thrust of the change.
Moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto ya moto
Na na na na na na na na na na na na na na na na na na na na na na na na na na na na
Make Every Commit Count
Every time you touch the codebase, you have a choice: leave it a little better, or leave it a little worse. Refactoring doesn’t have to be a grand event. Small improvements (extracting methods, renaming confusing variables, breaking apart long methods, etc.) add up over time. They prevent technical debt from piling up and make future changes easier and safer.
If you see something, fix something.
Always be refactoring!