Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Chris Kiehl

Rating No ratings yet

Data is the heart of your code. Data-oriented programming is a programming technique that enables you to precisely model domains and write large enterprise-scale applications that are oriented around the data they manage. Take a data-oriented approach to your Java applications, and you’ll enjoy simpler state management, improved readability, and no more state-related bugs! - This book teaches you how to use immutable strongly typed data effectively and take full advantage of the modern data-oriented features built into the Java language. Simplify your Java code with data-oriented programming! - In Data-Oriented Programming in Java and you’ll learn how to: - • Model your domain accurately using records, sealed classes, and pattern matching • Use objects to manage side-effects • Harness the power of plain data • Make illegal states impossible to represent • Let the data types guide your implementation • Never write another Null check or experience another NPE! - Data-Oriented Programming in Java shows you how to transform how you think about Java code by adopting a data-first mindset. Author Chris Kiehl has honed his data-oriented Java skills in the trenches of daily development at Amazon. This guide reveals those hard-earned techniques and approaches that will elevate your skills as a Java coder.

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 A practical guide to making Java code express its own meaning: model your domain with records, sealed types, and pattern matching so that illegal states simply cannot be written. Best for working Java developers on enterprise codebases who are tired of null checks, ambiguous `String` fields, and state bugs that tests never seem to catch. 【Book Arc】 - **Opening (~0%–10%)**: Frames the core thesis through a small but telling example — changing `String id` to a typed `UUID id` — and argues that most code under-specifies its data. Introduces the value/identity distinction that underpins everything later. - **Early (~10%–30%)**: Builds the vocabulary of values, data, and semantics. Shows how to compare the *meaning* of your data against the *meaning* of the type representing it, and treats any mismatch as a modeling smell. Covers value classes, fluent immutable APIs, and the trade-offs of introducing new types versus accepting "plain" ints and Strings. - **Early–Middle (~30%–40%)**: Moves into algebraic modeling — Product Types (records) and Sum Types (sealed interfaces) — and why knowing this algebra helps you communicate across languages and sketch problems tersely. Uses a checklist/template domain to work through modeling choices. - **Middle (~40%–50%)**: Extends data-orientation from data to *behavior*. Behaviors become discrete input-to-output transformations; wrapper types and enriched data types decouple methods from their external dependencies (databases, APIs, environment reads). - **Middle–Late (~50%+)**: Explores determinism, pure functions, and the tension between identity objects and plain data. Discusses where to draw the line and warns against zealotry — "basically deterministic" is often good enough. 【Key Takeaways】 - **Representation is the highest-leverage decision** (Opening): Choosing `UUID` over `String` for an ID eliminates an entire class of illegal states and the defensive code and tests they require. The book's central move is taking the "obvious" incremental step toward self-describing code. - **Values vs. identity objects** (Early): Values are immutable, have no identity, and cannot change; identity exists independently of any mechanism. Data-oriented programming models identity *with* values rather than through mutable objects. - **Compare meanings to debug your model** (Early): Hold the meaning of your data next to the meaning of its type. If a `double` represents an angle constrained to 0–360 degrees, 99.9999% of representable values are invalid — that gap is a modeling smell. - **Types are a trade-off, not a religion** (Early): Introducing a new type costs boilerplate (minimal with records) but buys safety, correctness, and understandability. The book explicitly warns against both reflexive "boilerplate" dismissal and over-typing everything into madness. - **Product and Sum Types are the algebra underneath** (Early–Middle): Records model "this AND that"; sealed interfaces model "this OR that." Knowing the algebra gives you a language-independent way to discuss and sketch designs. - **Model behaviors around data, not around void methods** (Middle): Behaviors are discrete state-to-state transformations — inputs produce outputs. Making them self-describing and self-enforcing prevents the "wrong invoice passed to the wrong method" class of bug. - **Good data types decouple methods from dependencies** (Middle): A single enriched record can unify multiple service calls and database reads so consumers never need to know about them. The open question the book raises: who is responsible for constructing it? - **Determinism is a spectrum, not a binary** (Late): Pure functions give you omniscience over outputs, but Java inevitably bridges identity objects and data. The book advises against zealotry — "basically deterministic" is usually just as good. 【Reading Tips】 - **Deep-read the early chapters on values, semantics, and type-meaning comparison.** These are the conceptual foundation; everything later is applied modeling. Skim if you already think in types, but don't skip the meaning-comparison exercise. - **Work the domain examples actively.** The book builds up a checklist/template domain and an invoice/late-fee domain across chapters, revising earlier models as it goes. Treat the revisions as the lesson, not the final code. - **Don't get stuck on the algebra section if it's not your thing.** The book itself says the set-theoretic view is "extracurricular." Take away the Product/Sum vocabulary and move on. - **Watch for the trade-off discussions.** The most valuable passages are where the author admits a refactoring is "expensive" or says "it depends" — those are the judgment calls you'll face at work. - **Note the null-safety thread.** The promise of never writing another null check is delivered through modeling, not through tooling; track how each modeling decision removes a null possibility. 【Coverage Limits】 These excerpts cover roughly the first half of the book (through the behavior-modeling and determinism chapters). Later chapters on side-effect management, pattern matching in depth, and full enterprise application structure are not represented here; the guide's Late/Ending arc is inferred from the blurb and later-chapter fragments only.
Page 12
o be an id in our domain is expressed directly in the code. This subtle shift in representation, despite being a single line, has a massive impact on our pro...
View in text
Excerpt 2
pairs, or other positional based data structures. Listing 2.44 combining results with positional data structures Optional<Person> mostPopular(List<Person> pe...
View in text
Excerpt 3
different options within a single idea (this OR that OR…). for day-to-day usage of Sum Types. We’re sticking with that one because viewing what’s going in th...
View in text
Excerpt 4
Access Object) do anything other than what the ORM blesses. One pattern I like is introducing a façade to tie things together. It does the grunt work of gett...
View in text
Excerpt 5
same almost binary operation-like thing as List. It’s just harder to see because the put() API doesn’t really fit the algebraic shape. However, if we swap to...
View in text
Excerpt 6
"field": "Region", "value": "EMEA" } } } That means our long-term goal of not writing these rules by hand is suddenly a lot more tractable. We could build a...
View in text
Excerpt 7
as a placeholder. Listing 10.20 Manifests lead to CSV data NOTES.md String -> JSON -> Manifest -> List<RawCsvRepresentation> #A We’re purposefully glossing o...
View in text
Excerpt 8
ivate Clock clock; private InvoiceService invoiceService; private RatingsAPI ratingsAPI; @BeforeEach void setup() { #A this.clock = Clock.fixed(Instant.now()...
View in text
Tags
AI categories
JavaProgramming LanguageSoftware
ISBN: 1633436934
Publish Year: 2026
Language: English
File Format: PDF
File Size: 16.3 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…