liveBook · Manning

Parameterization

As explained in Data-Oriented Programming in Java

Parameterization is the technique of defining a type or computation in terms of explicit parameters that specialize its behavior or representation.

Parameterization defines a type in terms of explicit parameters, allowing one model to represent different lifecycle states or carry state-specific information. For LateFee, a type parameter can encode which lifecycle a decision applies to, so the type system expresses that assessments handle drafts. section 5.4.4

Encoding a reviewed draft

A sealed ReviewedFee model can parameterize each outcome with LateFee<Draft>: Billable and NeedsApproval carry the draft, while NotBillable also carries a Reason. The parameter preserves the relevant lifecycle state across decisions. section 5.4.4

Listing 5.40 Representing the decision in our system
sealed interface ReviewedFee {
    record Billable(Latefee<Draft> fee)                      #A
        implements ReviewedFee{}
    record NeedsApproval(Latefee<Draft> fee)                 #A
        implements ReviewedFee{}
    record NotBillable(Latefee<Draft> fee, Reason reason)    #A
        implements ReviewedFee{}
}

Inspect the sealed decision model to see how LateFee<Draft> makes lifecycle information explicit in each outcome. section 5.4.4

How Data-Oriented Programming in Java covers it

How deep it goes
Demonstrates parameterized representations and their design payoff, but stops short of implementation detail.
Examples
Uses LateFee<Draft> inside Billable, NeedsApproval, and NotBillable decision variants.
What it assumes
Assumes that lifecycle information and domain decisions have already been identified.
What you can do after
Apply parameterization to encode lifecycle-specific business constraints before committing to implementation.
How it connects
Connects lifecycle modeling, type systems, data models, sealed interfaces, and business rules.

Also explained in

Compare how 3 books explain parameterization →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data-Oriented Programming in Java. The section links point to the parts of the book it draws on.