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:
- What capability does the interface represent?
- What does the coordinator know about its collaborator?
- What concrete details did you successfully keep out of the coordinator?
- Where did you use composition and why?
- Where did you use or reject inheritance and why?
- 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.