CS core subjects

Stage 2 of 8 · 8 lessons · ~5 weeks

Object-oriented programming and design

Classes, the four pillars, composition and the SOLID principles at an introductory level. The goal is code that is easy to change, not a list of definitions for the exam.

Start: Classes, objects and responsibilities

Lessons· one lesson for each topic, in this order

  1. 1Classes, objects and responsibilities
  2. 2Encapsulation
  3. 3Inheritance and when not to use it
  4. 4Polymorphism
  5. 5Abstraction, interfaces and abstract classes
  6. 6Composition over inheritance
  7. 7SOLID principles, at an introductory level
  8. 8Design patterns: a first handful

Do this

  • Model one real problem on paper: classes, responsibilities and relationships, before writing any code.
  • Build it in the language your course uses, with private fields and methods that protect its rules.
  • Replace one `if type == ...` chain with polymorphism.
  • Replace one inheritance relationship with composition and note what got simpler.
  • Write one before and after example for each SOLID principle in your own notes.
  • Implement Strategy and Observer once each in a small exercise.
  • Ask a classmate to add a feature to your program and note which parts they had to change.

Start with· follow one of these

  • CoursePaid
    Grokking SOLID Design Principles

    Design Gurus · Beginner · $50 one-time

    Each SOLID principle with a broken example and its fix, at a beginner-friendly pace

  • CourseFree
    Java Programming MOOC

    University of Helsinki · Beginner

    Free, exercise-heavy course whose second half is a thorough, tested introduction to OOP

Keep handy

Also worth your time

Before moving on: A small console program, such as a library or parking lot system, with a one-page class diagram and a short note that points to where you used encapsulation, polymorphism, composition and at least two SOLID principles.

Tauseef's advice
OOP exams reward definitions; jobs reward code that is easy to change. Write the program first, then refactor it twice: once to remove a type switch with polymorphism, once to replace an inheritance chain with composition. That is where the ideas stick.

Mark this stage as not done?