PrepZone Logo
PrepZone

Repository and Facade

Hide persistence and subsystem complexity behind narrow ports.

Why this matters

  • Repository port — detailed pointwise breakdown in the section below.
  • In-memory vs DB — detailed pointwise breakdown in the section below.
  • Facade over subsystems — detailed pointwise breakdown in the section below.
  • CampusOS library — detailed pointwise breakdown in the section below.
  • Patterns are forces and solutions — name the force before the pattern.
Dependency direction
Controller / FacadeHTTP or API entry
Serviceuse cases, orchestration
Domainentities, rules, invariants
Repositorypersistence port
Dependencies point inward — domain never imports infrastructure.

Overview

Hide persistence and subsystem complexity behind narrow ports. Study each section below in order — every list is interview-ready reference material.

Repository port

Points to cover

  • Definition — what Repository port 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

In-memory vs DB

Points to cover

  • Definition — what In-memory vs DB 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

Facade over subsystems

Points to cover

  • Definition — what Facade over subsystems 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

CampusOS library

Points to cover

  • Definition — what CampusOS library 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 "Repository port" on paper first, then in code
public final class RepositoryAndFacadeExample {
    // 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. Repository port — review this slice before mock interviews.
  2. In-memory vs DB — review this slice before mock interviews.
  3. Facade over subsystems — review this slice before mock interviews.
  4. CampusOS library — review this slice before mock interviews.

Test yourself

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