Which Code Smells to Fix First: A Cost-Weighted Prioritisation Framework

Not all smells deserve equal attention. This framework ranks smells by the ratio of annual cost to fix effort, giving you a data-driven order for remediation that maximises ROI per hour invested.

The Prioritisation Formula

Priority Score = (Annual Cost per Instance x Instance Count) / Fix Effort (hours)
Highest score = fix first. Score represents dollars saved per hour of refactoring invested.

The formula favours smells that are cheap to fix relative to their cost impact. Dead Code tops the ranking because removing it takes minutes but eliminates ongoing reading burden. God Classes rank lower despite the highest cost per instance because fixing them requires significant effort.

Quick Wins: Start Here

These smells are cheap to fix, low risk, and build momentum for larger refactoring efforts. Do these first to demonstrate value before tackling God Classes.

Dead CodeQuick Win

Highest ROI: delete and trust version control. Zero risk. 5-15 minutes per block. Immediate reduction in reading burden.

Fix: 15 minScore: 15,784
Lazy ClassQuick Win

Quick win: inline the class and remove one navigation hop. 30-60 minutes. Low risk.

Fix: 1 hrsScore: 3,946

Quick win: collapse unnecessary abstractions. If 'we might need this later' has been true for 6+ months, delete it.

Fix: 1 hrsScore: 3,946

Extract methods to replace 'what' comments. 15-30 minutes per block. Reduces stale comment risk.

Fix: 30 minScore: 7,892

Default Priority Ranking

Pre-calculated for one instance of each smell on a team of 8, using the mid inputs of our cost model at $180K fully-loaded cost per engineer. Fix hours are our own estimates. Your ranking will differ with instance counts: use the smell profile calculator.

#SmellSeverityModel cost/yrFix (hrs, est.)Priority Score
1Dead CodeQuick WinLow$4K0.2515,784
2Comments (as Smell)Quick WinLow$4K0.57,892
3Duplicate CodeHigh$15K35,077
4Feature EnvyHigh$15K35,077
5Primitive ObsessionMedium$8K24,033
6Long Parameter ListMedium$8K24,033
7Message ChainsMedium$8K24,033
8Lazy ClassQuick WinLow$4K13,946
9Speculative GeneralityQuick WinLow$4K13,946
10Long MethodHigh$15K43,808
11Inappropriate IntimacyHigh$22K63,692
12God ClassCritical$39K123,260
13Data ClumpsMedium$8K32,688
14Alt Classes/Diff InterfacesMedium$8K32,688
15Temporary FieldMedium$8K42,016
16Refused BequestMedium$8K42,016
17Data ClassLow$4K21,973
18Middle ManLow$4K21,973
19Shotgun SurgeryHigh$15K81,904
20Divergent ChangeHigh$15K101,523
21Switch StatementsMedium$8K61,344
22Parallel InheritanceHigh$15K121,269

Priority Score = model cost per instance a year / estimated fix hours. Higher score = fix first.

When NOT to Refactor

An honest prioritisation framework must include when refactoring is a waste of time. These are the situations where the cost of refactoring exceeds the benefit:

Code scheduled for replacement

If a module will be replaced within 3-6 months, refactoring it wastes effort on code that will be deleted. Exception: if the smelly code is causing production incidents before the replacement ships, tactical fixes (not structural refactoring) are warranted.

Isolated, stable modules

Code that works correctly, is rarely changed, and is well-tested does not benefit from refactoring. A God Class in a module that has not been modified in 12 months costs almost nothing in practice because nobody is reading, changing, or onboarding onto it.

Smells in test code

Test code has different cost dynamics. Long test methods that are descriptive and readable are fine. Duplicate setup code in tests is acceptable when it makes each test self-contained. Focus refactoring effort on production code first.

No test coverage for the refactoring target

Refactoring without tests is not refactoring; it is rewriting with hope. If the target code has no automated tests, the first step is to add characterisation tests before any structural changes. This is a cost you must include in the effort estimate.

Ready to build a business case? Calculate your costs and estimate refactoring ROI.

Updated November 2026