JGCRI / programing-resources

Repo for JGCRI software training resources
1 stars 0 forks source link

3. Writing Good Code - meaningful names #3

Closed bpbond closed 6 years ago

bpbond commented 7 years ago

Perhaps change the final code block to something like

initial_fish_stock = 4.5  # billion fish
for ocean_levels = 1, 20 {  # meters
ssmithClimate commented 7 years ago

Good idea, thanks. (Now looking at this I made another mistake {other than using for loops :), which is embedding a hard coded constant (e.g. "20") - I'll add a section on that later as well.

ssmithClimate commented 7 years ago

Pushed change addressing this. Added comments to “for loop” example, fixed bad style w/ hard coded limit, added text on that issue in DRY section, and added section on avoiding for loops.