30 lines
1.3 KiB
Markdown
30 lines
1.3 KiB
Markdown
---
|
|
title: Make the change easy, then make the easy change
|
|
date: 2024-10-04
|
|
permalink: daily/2024/10/04/make-the-change-easy--then-make-the-easy-change
|
|
tags:
|
|
- software-development
|
|
- clean-code
|
|
cta: ~
|
|
snippet: |
|
|
Make the change easy, then make the easy change.
|
|
---
|
|
|
|
This week, I've been working on a particular component that processes and displays live data from APIs.
|
|
|
|
As the data is live, it's constantly changing and it's unlikely I'll see all the different states and use-cases that the data could be in.
|
|
|
|
There's also no guarantee the API will be available and I also may need to work offline with no Internet access to connect to the API.
|
|
|
|
I'm reminded of the quote by Kent Beck:
|
|
|
|
> For each desired change, make the change easy (warning: this may be hard), then make the easy change.
|
|
|
|
In this case, to make the change easy, I need the data to be consistent, to see all the use-cases and permutations and to be available offline.
|
|
|
|
To make the change easy, I created a fake version of the service class that returns static data I can work with.
|
|
|
|
I can add whatever data I need to give me the examples and situations to work with and by implementing the same methods as the real service class, I can swap them without changing any other code.
|
|
|
|
Now I can make the easy change.
|