Why good design reduces maintenance cost in Software Engineering - Performance Analysis
Good design in software helps keep the work needed to fix or change code low over time.
We want to understand how design affects the effort as the software grows or changes.
Analyze the time complexity of maintaining two versions of a feature: one with good design and one without.
// Poor design example
function updateFeature(data) {
if (data.type === 'A') {
// many repeated checks and changes
} else if (data.type === 'B') {
// similar repeated code
}
// ... more types and repeated code
}
// Good design example
class Feature {
constructor(strategy) {
this.strategy = strategy;
}
update(data) {
this.strategy.update(data);
}
}
This shows a simple example where poor design repeats code, while good design uses clear structure.
Look at repeated code blocks and checks that happen every time the feature updates.
- Primary operation: Repeated conditional checks and duplicated code in poor design.
- How many times: Each update runs through many repeated steps, increasing effort.
As the feature grows with more types or changes, the poor design requires more repeated fixes.
| Input Size (number of changes) | Approx. Maintenance Effort |
|---|---|
| 10 | High due to repeated fixes |
| 100 | Much higher, effort multiplies |
| 1000 | Very high, hard to manage |
Pattern observation: Poor design effort grows quickly as changes increase, while good design keeps effort steady.
Time Complexity: O(n)
This means maintenance effort grows directly with the number of changes, but good design keeps the growth manageable.
[X] Wrong: "Adding more code quickly is fine; fixing it later won't be hard."
[OK] Correct: More code without good design means more repeated work and bugs, making fixes take longer over time.
Understanding how design affects maintenance shows you think ahead about code quality and long-term work, a key skill in software development.
"What if we added automated tests along with good design? How would that affect maintenance effort growth?"