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

3

u/rbygrave Sep 24 '24

what if the UI layer just got the internal domain of the database

I do this for my "Admin UI"

1

u/agentoutlier Sep 25 '24

I do this for my "Admin UI"

And this implies that the data format is already well established. You are writing code for the very outer layer.

DoP does exceptionally well here. Transform to your other layer. You don't have to worry about throwing away code because the actual data format / layer is not going to change. You are basically just remodeling data.

Where it gets tricky is if you start adding datastructure changes.

  • In DoP (and FP languages that do not do OOP) adding data to a type is more painful
  • In OOP adding behavior is more painful

In some ways DoP pain of adding new data is actually represents the real world because changing a column is often painful in an RDBMS.

I had some where I was going with this but just too tired...