Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
szabgab committed Mar 16, 2021
1 parent 3282b0b commit c921300
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
4 changes: 4 additions & 0 deletions python/examples/refactor/bad_variable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
data = ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn']
for i in data:
print(i)

4 changes: 4 additions & 0 deletions python/examples/refactor/good_variable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
celestical_objects = ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn']
for planet in celestical_objects:
print(planet)

2 changes: 1 addition & 1 deletion python/python.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"algorithm.md",
"scapy.md",
"turtle.md",
"refactor.md",
"refactoring.md",
"other.md"
]
}
8 changes: 0 additions & 8 deletions python/refactor.md

This file was deleted.

22 changes: 22 additions & 0 deletions python/refactoring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Refactor
{id: refactor}

## Refactoring example - change variable name
{id: refactoring-change-variable-name}

![](examples/refactor/bad_variable.py)

![](examples/refactor/good_variable.py)

## How to Refactor
{id: how-to-refactor}

* Write tests that will verify the behaviour (or at least compare the new behavior to the old behavior)
* Make a small change.
* Run the tests.

## Exercise: Fix deep indentation
{id: exercise-fix-deep-indentation}

![](examples/refactor/remove_deep_indentation.py)

0 comments on commit c921300

Please sign in to comment.