User Tools

Site Tools


haas:fall2020:common:helpances:protips

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
haas:fall2020:common:helpances:protips [2020/08/17 13:09] – created wedgehaas:fall2020:common:helpances:protips [2020/08/17 13:20] (current) – [PROTIP: always use descriptive variable names] wedge
Line 27: Line 27:
 </code> </code>
  
 +=====PROTIP: always use descriptive variable names=====
 +Oversight is one of the biggest sources of error in programming.
 +
 +Naming your variables "i", "x", "a", or similarly non-descript names does not help in your program's readability.
 +
 +Instead, go for contextually relevant things that pertain to the problem you are solving:
 +
 +  * instead of 'i' and 'j' for loop variables, use "index" or "index2" (or "inner" and "outer", "row" and "col[umn]")
 +  * instead of 'x' to store an accumulation or count, perhaps "tally", "sum", or "count"
 +
 +If **I** had a nickel for everytime a student asked //me// to explain **THEIR** code, I would be rich.
 +
 +=====PROTIP: comment as you go=====
 +Much like handwriting out your notes, it doesn't SEEM valuable, except you are exposing your brain and lending focus to important concepts making up your solution.
 +
 +Plus, you will start to problem solve better, simply from the added exposure (when it is fresh in your mind, and not some discouraging "bah! Have to go back and comment so I do not lose points" mindset).
haas/fall2020/common/helpances/protips.1597669776.txt.gz · Last modified: 2020/08/17 13:09 by wedge