Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Refactoring your Application to Data-Oriented P...

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
Avatar for José José
March 16, 2026

Refactoring your Application to Data-Oriented Programming

Data-Oriented Programming is a programming model paradigm, alternative to Object Oriented Programming, that allows you to organize your application code differently. Its goal is the same as Object Oriented Programming: enabling the extension of a given object model by adding new types and new behavior. Since Java is an Object Oriented language, it uses tools already there such as records, sealed types (mostly interfaces), exhaustive switch expressions, and pattern matching.
This hands-on lab gives you a simple application as a starting point and uses a step by step approach to guide you through a Data-Oriented Programming refactoring. Once this refactoring is done, it shows you how to add new types and behavior so you can compare with the Object Oriented approach. By the end of this workshop, you'll have a better understanding of Data-Oriented Programming and how and where you can apply its principles in your application.

Avatar for José

José

March 16, 2026
Tweet

More Decks by José

Other Decks in Education

Transcript

  1. Refactoring to Data Oriented Programming José Paumard Java Developer Relation

    Java Platform Group, Oracle Billy Korando Java Developer Advocate Java Platform Group, Oracle
  2. Tune in! 5 Copyright © 2026, Oracle and/or its affiliates

    Inside Java Newscast JEP Café Road To 25 series Inside.java Inside Java Podcast Sip of Java Cracking the Java coding interview
  3. 3/17/2026 Copyright © 2026, Oracle and/or its affiliates 8 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
  4. 3/17/2026 Copyright © 2026, Oracle and/or its affiliates 9 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
  5. 3/17/2026 Copyright © 2026, Oracle and/or its affiliates 10 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?
  6. 3/17/2026 Copyright © 2026, Oracle and/or its affiliates 11 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
  7. 3/17/2026 Copyright © 2026, Oracle and/or its affiliates 12 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
  8. 3/17/2026 Copyright © 2026, Oracle and/or its affiliates 13 Fixing

    the Application / DB Relation DB FlightEntity (Hibernate) Business Module
  9. 3/17/2026 Copyright © 2026, Oracle and/or its affiliates 14 Fixing

    the Application / DB Relation DB FlightEntity (Hibernate) Business Module Application of the Dependency Inversion Principle (SOLID)
  10. 3/17/2026 Copyright © 2026, Oracle and/or its affiliates 15 Fixing

    the Application / DB Relation DB FlightEntity (Hibernate) Business Module <I> <DTO>
  11. 3/17/2026 Copyright © 2026, Oracle and/or its affiliates 16 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
  12. 3/17/2026 Copyright © 2026, Oracle and/or its affiliates 17 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