PrepZone Logo
PrepZone

Open/Closed and Extension Points

Add behaviour with new types, not edited conditionals.

Why this matters

  • Growing switches — detailed pointwise breakdown in the section below.
  • Strategy as OCP — detailed pointwise breakdown in the section below.
  • Plugin registries — detailed pointwise breakdown in the section below.
  • Trade-offs — detailed pointwise breakdown in the section below.
  • SOLID is scored as refactor skill, not acronym recall.
Creational
Factorychoose implementation
Builderstep-by-step assembly
Structural
Decoratorstack behaviour
Facadesimple entry point
Behavioral
Strategyswap algorithm
Observernotify subscribers
Statebehaviour by mode
Pick the family first, then the specific pattern.

Overview

Add behaviour with new types, not edited conditionals. Study each section below in order — every list is interview-ready reference material.

Growing switches

Points to cover

  • Definition — what Growing switches means in one clear sentence
  • When to use — the force or smell that triggers this concept
  • CampusOS example — where this appears in parking, booking, or library modules
  • How to explain — pointwise bullets you can say aloud in an interview
  • Common mistake — what weak candidates do instead
  • Refactor move — one concrete change that improves the design

Strategy as OCP

Points to cover

  • Definition — what Strategy as OCP means in one clear sentence
  • When to use — the force or smell that triggers this concept
  • CampusOS example — where this appears in parking, booking, or library modules
  • How to explain — pointwise bullets you can say aloud in an interview
  • Common mistake — what weak candidates do instead
  • Refactor move — one concrete change that improves the design

Plugin registries

Points to cover

  • Definition — what Plugin registries means in one clear sentence
  • When to use — the force or smell that triggers this concept
  • CampusOS example — where this appears in parking, booking, or library modules
  • How to explain — pointwise bullets you can say aloud in an interview
  • Common mistake — what weak candidates do instead
  • Refactor move — one concrete change that improves the design

Trade-offs

Points to cover

  • Definition — what Trade-offs means in one clear sentence
  • When to use — the force or smell that triggers this concept
  • CampusOS example — where this appears in parking, booking, or library modules
  • How to explain — pointwise bullets you can say aloud in an interview
  • Common mistake — what weak candidates do instead
  • Refactor move — one concrete change that improves the design
Java
// CampusOS — apply "Growing switches" on paper first, then in code
public final class OpenClosedStrategyExample {
    // 1. Name entities from the problem statement
    // 2. Draw relationships before writing methods
    // 3. Introduce patterns only when a force appears
}

Quick recall

Everything you need if you only revisit this box.

  1. Growing switches — review this slice before mock interviews.
  2. Strategy as OCP — review this slice before mock interviews.
  3. Plugin registries — review this slice before mock interviews.
  4. Trade-offs — review this slice before mock interviews.

Test yourself

Answer these before moving on — recall is what makes it stick.