Skip to content

Commit 78d5bfd

Browse files
committed
Final clean up of grammar and instructions on this your turn for recent edits.
1 parent f205b9b commit 78d5bfd

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

your-turn/04-refactoring/readme.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66

77
We are going to use a project located in the same folder as this file called `smelly_podcast` (as in code smells). This is code we used to download some things from Talk Python To Me.
88

9-
It has been contorted to have many problems or [code smells](https://en.wikipedia.org/wiki/Code_smell). We'll use refactoring to freshen this up.
9+
It has been _contorted_ to have many problems or [code smells](https://en.wikipedia.org/wiki/Code_smell). We'll use refactoring to freshen this up.
1010

11-
**Note**: Before you first run this app, you'll need to make sure you have `requests` installed via pip.
11+
**Note**: Before you first run this app, you'll need to make sure you have a virtual environment active and `requests` installed via pip.
1212

1313
## Large method *smell*
1414

15-
Look at `program.py` and notice this somewhat complex app is actually just one big method, yuck. We'll use several refactoring to fix this.
15+
Look at `program.py` and notice this somewhat complex app is actually just one big method, yuck. We'll use several refactorings to fix this.
1616

1717
First, notice the section with the comment **"SHOW THE HEADER"**.
1818

1919
Take that small piece of code and make it its own method. Highlight the lines, choose **Refactor > Refactor this**.
2020

21-
Choose method and name it `show_header()`. Notice it was created below and called from your current location.
21+
Choose method and name it `show_header`. Notice it was created below and called from your current location.
2222

2323
After each refactoring, run the program to make sure it still works!
2424

@@ -45,7 +45,7 @@ Accomplish this by refactoring the `url` variable and choosing *inline variable*
4545
-----------------------
4646

4747

48-
Next up, we have **"GET SHOW ID RANGE"**. We want a method that will return both the `latest_show_id` as well as the `oldest_show_id`. This is interesting because you'll see that PyCharm knows about tuple packing/unpacking on method calls. Highlight both:
48+
Next up, we have the **"GET SHOW ID RANGE"** section. We want a method that will return both the `latest_show_id` as well as the `oldest_show_id`. This is interesting because you'll see that PyCharm knows about tuple packing/unpacking on method calls. Highlight both:
4949

5050
```python
5151
latest_show_id = max(episode_data.keys())
@@ -80,7 +80,7 @@ Let's move the data container and type first. Highlight these two lines and "mov
8080
Episode = namedtuple('Episode', 'title link pubdate show_id')
8181
episode_data = {}
8282

83-
**Note**: If you have **not** opened just the `smelly_podcast` folder as the project root, you will need to market the folder `smelly_podcast` as a **sources root** for that to work. It should be blue like this:
83+
**Note**: If you have **not** opened just the `smelly_podcast` folder as the project root, you will need to market the folder `smelly_podcast` as a **sources root** for that to work. It should be **blue** like this:
8484

8585
![](./sources-root.png)
8686

@@ -125,7 +125,7 @@ def main():
125125

126126
## Variable absence *smell*
127127

128-
Variable absence is something I just made up. There doesn't seem to be an agreed upon smell for it, but I'm sure you've seen it. Here's the deal. What does this mean:
128+
**Variable absence** is a smell I created. There doesn't seem to be an agreed upon smell for it, but I'm sure you've seen it. Here's the deal. What does this mean:
129129

130130
`result = 7 * max(inputs) * (match / count)`
131131

@@ -134,14 +134,14 @@ Let's try this one instead.
134134
```python
135135
largest_cell = max(inputs)
136136
ratio = (match / count)
137-
DICE_MULTIPLIER= 7
137+
DICE_MULTIPLIER = 7
138138

139139
result = DICE_MULTIPLIER * largest_cell * ratio
140140
```
141141

142-
Well, you'll still have to use your imagination. But it seems to do with a board game, rolling dice, etc. Why is one clear and the other isn't? The expression is computing many values inline. Once named, they are much clearer what they are and how they are combined.
142+
Well, you'll still have to use your imagination. But it seems to do with a board game, rolling dice, etc. Why is one clear and the other isn't? The expression is computing many values inline all at the same time. Once named, the pieces are much clearer.
143143

144-
Open `service.py`. Notice this line `dom.findall('channel/item')` appears multiple times. It represents the `items` from the RSS feed.
144+
Open `service.py`. Notice this line `dom.findall('channel/item')` appears multiple times. It represents the `items` elements from the RSS feed (part of the RSS 2.0 spec).
145145

146146
Make a variable for it by highlighting either single expression, choose refactor > variable. Name it something like `items`. Choose 2 locations!
147147

0 commit comments

Comments
 (0)