Working Effectively With Legacy Code — Changing Software (Part 1: Chapter 1)

Birat Rai
2 min readNov 19, 2018

--

This is Chapter 1 of the Working Effectively With Legacy Code series.

Part 1 : Mechanics of Change:

Episode 1: Changing Software

Software Changes

Software evolves as requirements change. And, changing code is what any software developer do their whole life.

There are ways that make changing code difficult and much easier. We tend to refactor code along our development cycle as necessities arise or software complexity increases.

Four Reasons to Change Software

There are four reasons to change software as listed in the book.

  1. Adding a Feature.
  2. Fixing a bug.
  3. Improving the design.
  4. Optimizing resource usage.

1. Adding a Feature

Feature is what the software users use to interact with the software. We constantly add feature so that we fulfill users need. There is a big difference between adding new behavior and changing old behavior.

"Behavior is the most important thing about software. It is what users depend on. Users like it when we add behavior, but if we change or remove behavior they depend on, they stop trusting us."

2. Fixing a bug.

What is fixing a bug? We need to differentiate between fixing a bug or adding a feature. Often times these are co-related.

For instance, the business wants to change “Send Email” button from bottom left to right. Is it adding a feature or fixing a bug? From developer’s perspective, this could be seen as a completely new feature. But, business might just think this as a bug fix.

3. Improving the design.

Software design needs architectural change as the complexity grows or necessity grows. We want to have a design intact so that software change will be more maintainable, keeping its behavior same. We improve the design by refactoring.

Refactoring differs from code cleanup, in the sense that “ We aren’t doing just low-risk things such as reformatting source code, or rewriting chunks of it, instead, we are making a series of small modifications, supported by tests to make the code easier to change”.

4. Optimizing resource usage.

Optimizing closely relates to refactoring, but optimization leads to better resource usage by the software. The resource might be efficient loading of data, usage of memory, usage of internet data, usage of battery in mobile devices etc.

Chapter 2: Legacy Code Series

References:

--

--