previous | start | next

## Cohesion

- What makes a good class?
  - A class should represent a single concept.
    - Point
    - Circle
    - Time
    - Product
    - Employee
  - Class names should be nouns (function names should be verbs).
- What makes a bad class?
- - If you can't tell from the class name what an object of the class is supposed to do, then you are probably not on the right track.
  - Example: What does a instance of a `PaycheckProgram` class do?
  - Do not turn an action into a class.
  - Example: `ComputePaycheck` is a function, not a class.
- The member functions and constants that the public interface of a class expose should be cohesive - all interface features should be closely related to the single concept that the class represents.
- If a class interface refers to multiple concepts, then that is a good sign that it may be time to use separate classes instead.

previous | start | next