-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
1,943 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Day 23: Refactor the legacy code after putting it under test. | ||
Refactor the `TripService` class to ensure Clean Code / SOLID principles | ||
|
||
Legacy code golden rules : | ||
`You cannot change any existing code if not covered by tests.` | ||
|
||
The only exception is if we need to change the code to add unit tests, but in this case, just automated refactorings (via IDE) are allowed. | ||
|
||
## Step by Step | ||
|
||
We use different steps that are all described separately (step-by-step md files): | ||
|
||
1. Cover the production code | ||
2. Improve confidence in our tests | ||
3. Refactor the production code | ||
4. Other refactorings | ||
|
||
## What did we use / learn ? | ||
- `Seams` | ||
- `Automated refactoring` via our IDE | ||
- Extract Method | ||
- Change Signature | ||
- Rename | ||
- `Mutation Testing` | ||
- Use `Higher Order Functions` to avoid duplication | ||
- Use `code coverage` as a driver | ||
- `Test Data Builder` | ||
- `Feature Envy` | ||
- `Sprout Class` | ||
- `TDD` | ||
|
||
>**Tip of the day1: Start testing from shortest to deepest branch.** | ||
>**Tip of the day2: Start refactoring from deepest to shortest branch.** | ||
### Share your experience | ||
|
||
How does your code look like? | ||
|
||
Please let everyone know in the discord. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Day 23: Refactor the legacy code after putting it under test. | ||
Refactor the `TripService` class to ensure Clean Code / SOLID principles | ||
|
||
Legacy code golden rules : | ||
`You cannot change any existing code if not covered by tests.` | ||
|
||
The only exception is if we need to change the code to add unit tests, but in this case, just automated refactorings (via IDE) are allowed. | ||
|
||
## Tips | ||
- Start testing from shortest to deepest branch | ||
- Start refactoring from deepest to shortest branch | ||
|
||
![Working with Legacy Code Tips](img/tips.png) | ||
|
||
## Step by Step | ||
1. [Cover the production code](steps/1.cover-the-code.md) | ||
2. [Improve confidence in our tests](steps/2.mutate-some-code.md) | ||
3. [Refactor the production code](steps/3.refactoring.md) | ||
4. [Other refactorings](steps/4.other-refactorings.md) | ||
|
||
## What did we use / learn ? | ||
- `Seams` | ||
- `Automated refactoring` via our IDE | ||
- Extract Method | ||
- Change Signature | ||
- Rename | ||
- `Mutation Testing` | ||
- Use `Higher Order Functions` to avoid duplication | ||
- Use `code coverage` as a driver | ||
- `Test Data Builder` | ||
- `Feature Envy` | ||
- `Sprout Class` | ||
- `TDD` | ||
|
||
Sources : | ||
- [Nicolas Carlo - understand legacy code](https://understandlegacycode.com/blog/key-points-of-working-effectively-with-legacy-code/#identify-seams-to-break-your-code-dependencies) | ||
- [Sandro Mancuso - Testing legacy with Hard-wired dependencies](https://www.codurance.com/publications/2011/07/16/testing-legacy-hard-wired-dependencies) | ||
- [Micheal Feathers - Working Effectively with Legacy Code](https://www.oreilly.com/library/view/working-effectively-with/0131177052/) | ||
|
||
<a href="https://youtu.be/LSqbXorkyfQ" rel="Sandro's video">![Sandro's video](img/video.png)</a> |
Oops, something went wrong.