Unit 12 · lesson

Checkpoint 4: Polymorphic Design

Design a small Java system in which multiple implementations collaborate through a stable contract.

Required architecture

Your submission must include:

  • at least one interface with a written behavioral contract;
  • at least two implementations of that interface;
  • at least one coordinator that receives a collaborator through its constructor;
  • a composition diagram showing responsibilities;
  • either one justified inheritance relationship or an explicit written decision rejecting inheritance where it would be tempting;
  • one polymorphic call site that uses the broad contract without ordinary concrete-type branching.

Behavioral evidence

Run the same caller or shared cases against at least two implementations.

Include one deliberate implementation that violates a documented behavior while still compiling. Your evidence must detect the violation.

Dispatch evidence

If you use inheritance or multiple interface implementations, trace:

declared variable/parameter type
runtime object type
operation invoked
implementation selected
observable result

Change-impact test

Change one requirement belonging to one collaborator. Show which component changed and which coordinator/other component remained untouched.

Rerun regression cases for the unchanged behavior.

Design defense

Answer:

  1. What capability does the interface represent?
  2. What does the coordinator know about its collaborator?
  3. What concrete details did you successfully keep out of the coordinator?
  4. Where did you use composition and why?
  5. Where did you use or reject inheritance and why?
  6. What behavioral rule can the compiler not enforce for you?

Mastery standard

A hierarchy diagram by itself is not object-oriented design evidence. The submission must show contracts, substitution, responsibility boundaries, runtime behavior, and change impact.