Skip to content
academia.sh

Course Intermediate

Programming Paradigms

By the end of this course

Start course

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.

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. 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.

02

Functional Programming

Testing the pure function's referential transparency by running it, eliminating shared state with immutable data, pulling behavior out into a function parameter, pipeline composition, the split between the functional core and the imperative shell, and the two paradigms' criterion-based choice within the same system.

  1. 01 Pure Functions Freedom from side effects and referential transparency: testing, by actually running it, whether a call can be replaced with its value; how behavior shifts in the impure version; and comparing the two versions by the line count of the fixture their tests require.
  2. 02 Immutability Eliminating shared state: counting the silent changes a shallow copy leaves behind, comparing the object counts that deep copying and structural sharing produce, and enforcing the rule with freezing.
  3. 03 Higher-Order Functions Parameterizing behavior: writing the same fee rule with a flag parameter, a lookup table, and a function parameter, and counting the lines touched and the core's decision points across the three versions when a new rule is added.
  4. 04 Composition Building large behavior from small functions: splitting the fee calculation into a four-step pipeline, counting how many tests the same defect drops across two designs, and measuring how many cents the result shifts when two steps swap places.
  5. 05 Pushing Side Effects to the Boundary The functional-core, imperative-shell arrangement: moving file reading, the clock, and log writing out of the computation into an outer layer, and comparing the number of tests that require a fake dependency and the number of lines that touch the outside world across the two arrangements.
  6. 06 Mixing Paradigms Using two models together in the same system: an object-heavy and a function-heavy model of carrier options, counting how many files a new operation and a new type touch in each model, and tying the choice to a measured criterion.

Start typing to search.

↑↓ Esc navigate · open · close