Skip to content

Commit

Permalink
renumber exercises in slides and a dd a bit of extra detail
Browse files Browse the repository at this point in the history
  • Loading branch information
AmyOctoCat committed Jun 27, 2024
1 parent c71c31b commit 28e9359
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
4 changes: 2 additions & 2 deletions slides/_comments_docstrings.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ def calculate_gyroradius(mass, v_perp, charge, B, gamma=None):



## Exercise 4 {.smaller}
## Exercise 5 {.smaller}

Go to exercise 4 and examine the comments:
Go to exercise 5 and examine the comments:

- Is there any dead code?
- How is it best to handle it?
Expand Down
4 changes: 2 additions & 2 deletions slides/_formatting.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,9 @@ Get a rating.
- [emacs](https://www.emacswiki.org/emacs/PythonProgrammingInEmacs)


## Exercise 3 {.smaller}
## Exercise 4 {.smaller}

Go to exercise 3 and:
Go to exercise 4 and:

- install pylint
- run pylint on `precipitation_climatology.py`
Expand Down
2 changes: 1 addition & 1 deletion slides/_fstrings_magic_config.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ print(config)
<!-- ------------------------------------------------------------------------------ -->


## Exercise 5 {.smaller}
## Exercise 6 {.smaller}

:::: {.columns}

Expand Down
29 changes: 26 additions & 3 deletions slides/_naming_for_clarity.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ A few naming tips and conventions:

Some examples:

- `ms`, `chclt`, `stm` --> `mass`, `chocolate`, `stem`
- `array`, `list`, `age_int`, `country_set` --> `dogs`, `cats`, `age`, `countries`
- `purple`, `not_plant`, `sidekick` --> `is_purple`, `is_plant`, `has_sidekick`
- Pronounceable names without abbreviations: \
`ms`, `chclt`, `stm` --> `mass`, `chocolate`, `stem`
- Naming for the content, not the type: \
`array`, `list`, `age_int`, `country_set` --> `dogs`, `cats`, `age`, `countries`
- Naming booleans: \
`purple`, `not_plant`, `sidekick` --> `is_purple`, `is_plant`, `has_sidekick`

## Explaining Variables

Expand All @@ -45,3 +48,23 @@ validate_phone_number_pattern = "^\\+?[1-9][0-9]{7,14}$"
re.match(validate_phone_number_pattern, "+12223334444")
```

## Exercise 3 {.smaller}

Look through the code for any names of methods or variables that could be improved or
clarified and update them. Note if you are using an IDE like Intellij or VSCode,
you can use automatic renaming.
Can you find an example from each of the suggestions listed below?
Does this make the code easier to follow?

Consider the following:

- The name should show the intention, think about how someone else might read it (this could be future you)
- Use pronounceable names e.g. `mass` not `ms`, `stem` not `stm`
- avoid abbreviations and single letter variable names where possible
- One word per concept e.g. choose one of `put`, `insert`, `add` in the same code base
- Use names that can be searched
- Describe content rather than storage type
- Naming booleans, use prefixes like `is`, `has` or `can` and avoid negations like `not_green`
- Plurals to indicate groups, e.g. a list of dog objects would be `dogs`, not `dog_list`
- Keep it simple and use technical terms where appropriate
- Use explaining variables

0 comments on commit 28e9359

Please sign in to comment.