liveBook · Manning

Functional core

As explained in Data-Oriented Programming in Java

The deterministic core is the central part of an application containing domain logic whose results do not depend on side effects or nondeterministic interactions.

A functional core concentrates deterministic domain logic in a boundary that depends only on its inputs. Database calls, randomness, clocks, and external services remain outside it, so dependency arrows flow outward toward an imperative shell. section 6.2 section 11.2

A practical design separates the work into two areas:

  • Keep pure transformations such as collecting past-due invoices, building fee drafts, and assessing drafts inside the core. section 6.2
  • Push billing APIs, approval services, customer facades, rules lookup, and current-date access outside the core. section 6.2
  • Give the boundary an explicit home such as a Core class or package, while treating that organization as a convention rather than a requirement. section 6.3
  • Pass time, ratings, and other environmental values as data instead of retrieving them inside domain functions. section 11.2

Late-fee assessment

A function such as isPastDue(invoice, rating, currentDate) can decide whether an open standard invoice exceeds its rating-based grace period without consulting a clock or ratings API. The surrounding shell obtains those values and supplies them. Tests then assert directly on inputs and outputs, including generated account or invoice states. section 11.2 section 6.2

Listing 6.28 The simplified view of how data flows through our program
                            NOTES.md
-------------------------------------------------------------------
// step 1: collect the past due
List<Invoice> -> List<PastDue>   
 
// Step 2: use those to build the draft
List<PastDue> -> LateFee<Draft>           
 
// Step 3: decide what to do with the draft
LateFee<Draft> -> (Billable OR NotBillable OR NeedsReview
 
// then depending on what we decided, either:
// Step 4.1: submit billable items 
Billable -> (LateFee<Billed> OR LateFee<Rejected>) 
 
// OR Step 4.2: Start the approval process for those that need it
NeedsReviewed -> LateFee<InReview>
 
// OR Step 4.3: keep the non-billable data for posterity  
NotBillable -> LateFee<Rejected> 

Trace the late-fee data flow from past-due invoices through draft assessment and the separate billing, approval, or rejection paths. section 6.2

How Data-Oriented Programming in Java covers it

How deep it goes
Explains dependency boundaries, code placement, and input-output testing, but stops short of prescribing one package or class structure.
Examples
Uses late-fee processing, past-due invoices, CSV deserialization, generated account states, and value-based assertions.
What it assumes
Assumes familiarity with domain models, Java functions, records, collections, dates, and external service dependencies.
What you can do after
Apply via pure functions and input-output tests that transform, generate, and compare domain data without configuring external dependencies.
How it connects
Connects determinism with side effects, imperative shell, data-oriented architecture, domain modeling, and input-output testing.

Also explained in

Compare how 3 books explain functional core →

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.