Slide 1

Slide 1 text

Refactoring your Application to Data Oriented Programming The Amber Project José Paumard Java Developer Advocate Java Platform Group Antoine Dabot-Durand SCIAM Ana-Maria Mihalceanu Senior Developer Advocate Java Platform Group

Slide 2

Slide 2 text

https://twitter.com/ammbra1508 https://mastodon.social/@ammbra1508 https://github.com/ammbra “DevOps Tools for Java Developers” guest author https://dev.java

Slide 3

Slide 3 text

Antoine Sabot-Durand Java Champion IT Lead at SCIAM Former CDI spec lead Former MicroProfile Health & Fault Tolerance spec lead Follow me on Bluesky: @antoine.sabot-durand.net

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

4/17/2025 Copyright © 2023, Oracle and/or its affiliates 5 https://dev.java/

Slide 6

Slide 6 text

4/17/2025 Copyright © 2025, Oracle and/or its affiliates 6 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 7

Slide 7 text

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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

4/17/2025 Copyright © 2025, Oracle and/or its affiliates 9 https://bit.ly/devoxxfr25-dop-lab SSID : devoxxfr-hol Passwd : hola#4321

Slide 10

Slide 10 text

4/17/2025 Copyright © 2025, Oracle and/or its affiliates 10 Structure of the Lab

Slide 11

Slide 11 text

4/17/2025 Copyright © 2025, Oracle and/or its affiliates 11 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 12

Slide 12 text

4/17/2025 Copyright © 2025, Oracle and/or its affiliates 12 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 13

Slide 13 text

4/17/2025 Copyright © 2025, Oracle and/or its affiliates 13 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 14

Slide 14 text

4/17/2025 Copyright © 2025, Oracle and/or its affiliates 14 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 15

Slide 15 text

4/17/2025 Copyright © 2025, Oracle and/or its affiliates 15 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 16

Slide 16 text

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

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

4/17/2025 Copyright © 2025, Oracle and/or its affiliates 19 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 20

Slide 20 text

4/17/2025 Copyright © 2025, Oracle and/or its affiliates 20 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