Overview

Today we’re going to focus on applying the principles of good design to classes so that you can better organize your projects early on.

Basic Learning Objectives

Before class, you should be able to:

  • Identify similarities between effective function design and class design
  • Define the single responsibility principle
  • Define cohesion
  • Define the open-closed principle

Advanced Learning Objectives

After class, you should be able to:

  • Write and refactor classes to have a single responsibility, tight cohesion, and follow the Open-Closed principle

Readings

To achieve the basic learning objectives, you can read the following in Clean Code (the parts that refer to Java specifically are still generally applicable in Python):

  • Ch 10 “Classes”

Checks

Submit answers to the following on Moodle:

  • What is the single responsibility principle?
  • What is the main similarity between effective function and class design?
  • What is cohesion in terms of class design?
  • What is the open-closed principle?