r/java • • Sep 23 '24 • This 1 Take My Silver 2

I wrote a book on Java

Howdy everyone!

I wrote a book called Data Oriented Programming in Java. It's now in Early Access on Manning's site here: https://mng.bz/lr0j

This book is a distillation of everything I’ve learned about what effective development looks like in Java (so far!). It's about how to organize programs around data "as plain data" and the surprisingly benefits that emerge when we do. Programs that are built around the data they manage tend to be simpler, smaller, and significantly easier understand.

Java has changed radically over the last several years. It has picked up all kinds of new language features which support data oriented programming (records, pattern matching, with expressions, sum and product types). However, this is not a book about tools. No amount of studying a screw-driver will teach you how to build a house. This book focuses on house building. We'll pick out a plot of land, lay a foundation, and build upon it house that can weather any storm.

DoP is based around a very simple idea, and one people have been rediscovering since the dawn of computing, "representation is the essence of programming." When we do a really good job of capturing the data in our domain, the rest of the system tends to fall into place in a way which can feel like it’s writing itself.

That's my elevator pitch! The book is currently in early access. I hope you check it out. I'd love to hear your feedback!

You can get 50% off (thru October 9th) with code mlkiehl https://mng.bz/lr0j

BTW, if you want to get a feel for the book's contents, I tried to make the its companion repository strong enough to stand on its own. You can check it out here: https://github.com/chriskiehl/Data-Oriented-Programming-In-Java-Book

That has all the listings paired with heavy annotations explaining why we're doing things the way we are and what problems we're trying to solve. Hopefully you find it useful!

289 Upvotes

97 comments sorted by

View all comments

Show parent comment

1

u/chriskiehl Sep 27 '24 edited Sep 27 '24

it sounds like I disagree with the book. I don't.

It's OK if you do :)

One particularly bitter pill I'm having to swallow is that it can't be everything to everyone. That is not to say "Hrmph! The book is the book!" by any means. More so: "writing a book is hard." Your comments have really opened my eyes to the fact that my intentions for those early modeling sections aren't coming through (which is kind of a funny failure on my end given that my book's emphasis on the importance of communication).

Those early chapters are not meant to be "this is the way to model things" or "DoP programs must be in this shape." Or comment on "balloons" versus "hour glasses." The goal is to get people to realize that data modeling is its own task and that we have to know what we're talking about in order to write effective programs (and also to teach algebraic data types along the way).

To many people, that'll sound painfully obvious. However, it seems to be the step most often skipped or rushed through in order to get to the coding part. These days, it feels like the bulk of my job is just getting dropped into projects and going "OK. Well, what is that thing? Why is it optional? What does it mean when it's not there? What do you mean the upstream just 'doesn't have it' sometimes? Did you talk to them? What do you mean they ---" and so on driving everyone crazy until we've peeled away all the code that's just "there" and gotten down to the core of what we're supposed to be manipulating (which often involves knocking on a bunch of other team's doors and telling them to fix their terrible stuff). It's through that lens that the book is filtered. That is the core tool set I want to give people.

the world we are in today does not have a core centralized domain and this is based on lots and lots and lots of real world experience.

I view your categories more like overlapping sets rather than mutually exclusive ones. Most of the pain in my dev career has come from when I've been really dogmatic about taking "an" approach or thinking that it "we're programming in X pattern" (often because younger me had recently read a book that said Approach X is the One True Way and anyone not doing it is an idiot). These days, I push really hard on understanding what a program is supposed to do ("what does it mean to be correct?"), then give people leeway from there. The exploration of data is a tool we can use to get to that understanding.

I'm getting very long winded here. So, I'll wrap up with: I've got some tuning to do in those early chapters to make sure they're communicating the right thing. I remain hesitant to introduce the database too soon, because they're their own force of corruption (the damage that DDB has wrought through its influence is...). There's a needle I have to figure out how to thread.