I THE PREMISE

Two paths fork before you. Both are correct. Both are wrong. The dilemma is precisely the recursion of choosing between them.

— Transcript opens. The defendant is the visitor. The visitor is the court.

II EXHIBIT A

FILED — 03:14, NIGHT SESSION

COMPOSITION

A small object that holds another small object. Behavior is borrowed by reference, not by birthright. The object is what it does, not what it descends from.

SEE: blob.svg, line 14, lower-left corner of the exhibit frame.

A·1 A·2 A·3 A·4
// Exhibit A — composition
const printer = {
  driver: attachDriver(),
  queue:  attachQueue(),
  log:    attachLog(),
};

printer.driver.send(job);
printer.log.audit(job.id);
// nothing inherited. nothing implied.

FIG. A — printer assembled by composition. Each capability is an object, swappable, reattachable, mockable. No parent. No protected method. Behavior is a list, not a lineage.

III THE CASE FOR A

1. The court will note that composition admits its dependencies in writing. Each attached driver is a noun on the page; nothing is inherited from a parent the reader cannot see. The transcript is complete.

2. The court will further note that composition tolerates substitution without ceremony. Replace the driver, the queue, the log — the surrounding object continues to function, untraumatized. Refactoring becomes mundane.

3. Tests, your honor, write themselves. Every dependency arrives at the door already labeled. The mock is the original, in lighter clothing.

4. Inheritance, by contrast, requests trust. The base class is not in the room. The base class is on a different floor, in a different file, under a different mood. The court has been here before.

FOOTNOTE A — Composition trades the elegance of implicit re-use for the burden of explicit wiring. Every attached object is a hand-soldered wire. The brief acknowledges this. The brief proceeds anyway.

FOOTNOTE A·ii — The defense reserves the right to contradict itself in Station V.

FOOTNOTE A·iii — The defense expects to do so.

IV EXHIBIT B

FILED — 03:41, NIGHT SESSION

INHERITANCE

A small object descends from a larger one. Behavior arrives by inheritance, before any line of code is read. The object is what its ancestors were, plus a single override.

SEE: blob.svg, upper-right corner of the exhibit frame, rotating counter-clockwise.

B·1 B·2 B·3 B·4
// Exhibit B — inheritance
class Printer extends Device {
  send(job) {
    super.send(job);
    this.audit(job.id);
  }
}

new Printer().send(job);
// the lineage carries the rest.

FIG. B — printer assembled by inheritance. The chain of ancestors carries the unspoken half of the implementation. The reader is asked to trust that what is unwritten is also correct. The reader, sometimes, is correct.

V THE CASE FOR B

1. The court will observe that inheritance admits a thesis: like belongs with like. A printer is a device. A scanner is a device. The taxonomy is older than the code, and the code is right to honor it.

2. The court will further observe that inheritance is the shorter document. Three lines accomplish what composition wires across thirty. Brevity has its own honesty.

3. The reader who fears a base class has not yet learned to read. The base class is not hidden. The base class is filed. The reader who refuses to open the file is, with respect, the dilemma — not the inheritance.

4. Composition, by contrast, asks the reader to assemble the meaning of the object every time. The reader becomes the assembler. The reader is, eventually, tired.

FOOTNOTE B — Inheritance trades the courage of explicit assembly for the gravity of an ancestor. Every parent class is a contract the descendant cannot rewrite. The brief acknowledges this. The brief proceeds anyway.

FOOTNOTE B·ii — The prosecution reserves the right to be reversed in Station VI.

FOOTNOTE B·iii — The prosecution expects to be.

VI CROSS-EXAMINATION

A → COMPOSITION

Behavior is a list of attached parts. [B objects: a list cannot be inherited; a list must be built every time.]

Refactoring is mundane. [B objects: refactoring is mundane only because the assembly was tedious to begin with.]

Tests write themselves. [B objects: tests write themselves because the dependencies are fictional.]

The transcript is complete. [B objects: the transcript is long. those are not the same thing.]

B → INHERITANCE

Like belongs with like. [A objects: like belongs with like only until like must change without permission of the parent.]

Brevity has its own honesty. [A objects: brevity is honest only when the absent code is also honest.]

The base class is filed, not hidden. [A objects: the base class is filed in a folder, the folder is filed in a project, and the project is filed in a regret.]

Composition tires the reader. [A objects: clarity is, sometimes, the labor it asks for.]

The court adjourns the cross. Neither side has yielded. Both sides have been heard. The dilemma persists, and is louder.

VII THE VERDICT

The verdict is the visitor's, not the page's.

VIII THE APPEAL

APPEAL FILED.

The defendant moves the court to vacate the verdict on grounds that no verdict was issued.

The court grants the motion. The transcript reopens.

The dilemma is recursive. The pan begins again — at the right edge — already underway.

DOCKET № 7741-α — REOPENED. ADJOURNED. REOPENED.

I II III IV V VI VII VIII