01
Structural and Object-Oriented Programming
The toolset that runs from disciplining control flow to object responsibility: the selection criteria for encapsulation, abstraction, inheritance, and polymorphism, the decision between an interface and an abstract class, the fragile base class problem, and each choice's measured cost.
- 01 Structural Programming Showing that a paradigm is a splitting decision rather than a syntax: measuring the number of independent paths, exit points, and the number of cases branch coverage requires across a flagged and a split version of the same fee-calculation flow.
- 02 Encapsulation Encapsulation as the tool that determines an invariant's owner: applying the same sequence of operations to an open-field and a closed-field version of the same consignment, counting how many objects fall into a corrupted state, and where protection breaks when a return value is not encapsulated.
- 03 Abstraction Separating exposed name count from known detail as abstraction's measure: counting the detail known by clients across a representation-exposed and a representation-hidden presentation of the same tariff, comparing how many clients break when the representation changes, and measuring the cost of hiding.
- 04 Inheritance Separating inheritance's two distinct promises: implementation sharing is measured by line count, the subtype relationship by a three-clause fee contract; a subclass that complies with the contract and one that does not are run through the same client, and the number of wrong results the noncompliant version produces is counted.
- 05 Polymorphism Implementing subtype, parametric, and ad hoc polymorphism separately on the same tariff problem: counting the files touched on each path when a new tariff type and a new operation are added to the system, and showing the contrast between the two directions of extension.
- 06 Interfaces and Abstract Classes The selection criterion for two abstraction tools: building two arrangements where shared behavior is split between an abstract class and an interface, showing by running code that single inheritance breaks when a carrier needs two abstractions at once, and counting the number of repeated lines.
- 07 Composition Over Inheritance Measuring the fragile base class problem: an implementation change in the superclass that does not change its own behavior silently breaking the subclass's counter in 200 out of 200 objects, the same change producing no deviation in the composed version, and counting composition's forwarding cost.
- 08 Object Responsibility Comparing an anemic data carrier with an arrangement that keeps behavior with the data: counting how many files the same two rules are written in, a search-based update missing one location when the rule changes, and measuring the inconsistency that shows up in 20 out of 40 shipments.