Slide 1

Slide 1 text

Refactoring your Application to Data Oriented Programming The Amber Project José Paumard Java Developer Advocate Java Platform Group Billy Korando Senior Developer Advocate Java Platform Group

Slide 2

Slide 2 text

@billykorando.bsky.social [email protected] https://dev.java

Slide 3

Slide 3 text

@josepaumard.bsky.social https://dev.java

Slide 4

Slide 4 text

3/21/2025 Copyright © 2025, Oracle and/or its affiliates 4 https://dev.java/

Slide 5

Slide 5 text

3/21/2025 Copyright © 2025, Oracle and/or its affiliates 5 Tune in! Inside Java Newscast JEP Café Road To 21 series Inside.java Inside Java Podcast Sip of Java Cracking the Java coding interview

Slide 6

Slide 6 text

https://marketplace.eclipse.org/content/java-24-support-eclipse-2025-03-435

Slide 7

Slide 7 text

https://www.jetbrains.com/idea/download/

Slide 8

Slide 8 text

3/21/2025 Copyright © 2025, Oracle and/or its affiliates 8 https://bit.ly/javaone25-dop-lab javaone25 javaturns30

Slide 9

Slide 9 text

3/21/2025 Copyright © 2025, Oracle and/or its affiliates 9 Structure of the Lab

Slide 10

Slide 10 text

3/21/2025 Copyright © 2025, Oracle and/or its affiliates 10 Is it new? The Expression Problem: how to extend statically typed data abstractions, in representations and behavior, without having to recompile the existing code. User-defined Types and Procedural Data Structures as complementary approaches to Data Abstraction." Reynolds, John C. (1975). . New Directions in Algorithmic Languages (PDF). IFIP Working Group 2.1 on Algol. pp. 157–168. Foundations of Object-Oriented Languages (FOOL), Cook, William (1990), REX School/Workshop. Lecture Notes in Computer Science. Vol. 489. Noordwijkerhout. Data Oriented Programming

Slide 11

Slide 11 text

3/21/2025 Copyright © 2025, Oracle and/or its affiliates 11 Polymorphism - Add new subtypes - No new operations Wadler’s Answer Pattern Matching - Add new operations - No new subtypes You cannot get both  If you are not the owner of the code: Phil Wadler

Slide 12

Slide 12 text

3/21/2025 Copyright © 2025, Oracle and/or its affiliates 12 Because it has to do with long term maintenance of your applications When your business requirements evolve: 1) How can you add behavior to your Object Model? 2) Can you remove the behavior that becomes obsolete? Why is This Problem Interesting?

Slide 13

Slide 13 text

3/21/2025 Copyright © 2025, Oracle and/or its affiliates 13 Structure of the Lab: Step 0 3 types of relationship: 1) Push 2) Pull 3) Pubsub A_Database B_Price-monitoring C_GUI D_Fligt-BP

Slide 14

Slide 14 text

3/21/2025 Copyright © 2025, Oracle and/or its affiliates 14 Structure of the Lab: Step 1 3 types of relationship: 1) Push 2) Pull 3) Pubsub A_Database B_Price-monitoring C_GUI D_Fligt-BP

Slide 15

Slide 15 text

3/21/2025 Copyright © 2025, Oracle and/or its affiliates 15 Fixing the Application / DB Relation DB FlightEntity (Hibernate) Business Module

Slide 16

Slide 16 text

3/21/2025 Copyright © 2025, Oracle and/or its affiliates 16 Fixing the Application / DB Relation DB FlightEntity (Hibernate) Business Module Application of the Dependency Inversion Principle (SOLID)

Slide 17

Slide 17 text

3/21/2025 Copyright © 2025, Oracle and/or its affiliates 17 Fixing the Application / DB Relation DB FlightEntity (Hibernate) Business Module

Slide 18

Slide 18 text

3/21/2025 Copyright © 2025, Oracle and/or its affiliates 18 Refactoring to Data Oriented Programming - About creating sealed types, carrying only state Record FTW! - And adding behavior outside of these types Pattern Matching FTW! Structure of the Lab: Step 2

Slide 19

Slide 19 text

3/21/2025 Copyright © 2025, Oracle and/or its affiliates 19 Final test: adding a new type, how does it go? Initial situation: you support simple flights Extension: you need to support multileg flights Structure of the Lab: Step 3