Practice: Code Quality

Required Practice

This week, you won't be doing a CodeCheck exercise for your practice; however, you will be submitting some practice to Gradescope.

Your task is as follows:

  1. Read through this website on Code Smells. Some of the examples used here are other than Python, but the concepts still apply.
  2. Visit the Gradescope assignment (/assignments/practice__code_quality.pdf), and answer some questions about what you've learned.

Additional Practice

This practice section will focus on the concept of code reviews: Reading through code in order to make it better, refactoring it as you see opportunities to do so.

Let's start by watching the following video where you can see a small code review in practice - you don't have to keep watching past 13:00

Your practice is to apply the same spirit on your own!

  • Reach out to a classmate and share a code snippet of yours with them for them to review, give them feedback on some of their code in exchange.
  • Go through your midterm project code and review it. What improvements can you find?
  • Go through your programming 1 final project and review it. What improvements can you find?

While we cover some big ideas in this week's content, here are a few other small things to look for - these are often called "code smells":

  • Are there poorly named variables?
  • Is there repeated code?
  • Are there random numbers used across the program?
  • Is there inconsistent style and naming?
  • Are there obvious ways to break the program?