-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split loop learning hour and refactoring description
- Loading branch information
1 parent
9802199
commit 2e190b8
Showing
5 changed files
with
56 additions
and
1 deletion.
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
--- | ||
layout: code_smell | ||
title: Loops | ||
name: loops | ||
source: Martin Fowler | ||
--- | ||
|
||
|
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,13 @@ | ||
--- | ||
theme: refactoring | ||
title: Split Loop | ||
name: split_loop | ||
code_smell: divergent_change | ||
kata: theatrical_players | ||
difficulty: 3 | ||
author: emilybache | ||
--- | ||
|
||
# Split Loop | ||
|
||
This learning hour is still being developed. |
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,32 @@ | ||
--- | ||
layout: refactoring | ||
title: Split Loop | ||
source: Emily Bache | ||
source_url: https://refactoring.com/catalog/splitLoop.html | ||
code_smells: loops,divergent_change | ||
learning_hours: split_loop | ||
--- | ||
|
||
# Split Loop | ||
This is one of the refactorings in Martin Fowler's book. Often this refactoring opens up for a lot of other useful changes. | ||
|
||
## Examine | ||
A loop is of itself a code smell, but even more so when it does more than one thing, which implies Diverent Change. | ||
|
||
## Prepare | ||
Identify the loop you want to split, and in particular which lines within it that hang together and need to be separated from the others. You may need to do some 'introduce variable' refactorings and 'slide statement' refactorings to gather all the relevant parts of the loop together. | ||
|
||
## Implement | ||
|
||
* Tests all passing | ||
* Select the whole loop and duplicate it. | ||
* In one copy of the loop, delete everything except the lines you want to split. | ||
* In the other copy of the loop, delete only the lines you want to split. | ||
* Tests all passing. | ||
|
||
## Clear | ||
Double-check the remaining logic in the original loop makes sense and that you didn't delete too much by mistake. | ||
|
||
## Follow up | ||
Often you now want to extract a method for the new loop, or turn it into a pipeline. | ||
You might identify another part of the old loop that also needs to be split. |
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,8 @@ | ||
--- | ||
layout: tdd_guide | ||
title: Newsletter | ||
--- | ||
|
||
# Newsletter and Free Guide to TDD Heuristics | ||
|
||
Please use the form below to sign up for our newsletter and receive your free guide. |