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

Refactorer votre code vers le Data Oriented Pro...

José
April 17, 2025

Refactorer votre code vers le Data Oriented Programming

La Programmation Orienté Données est une approche alternative à la Programmation Objet, qui vous permet d'organiser votre code différemment. Elle s'appuie sur les records, les types scellés, les switch expressions exhaustives, et le pattern matching. Ce lab part d'une application simple, qui ressemble à une application legacy et vous guide pas à pas vers la réorganisation du code en appliquant tout d'abord les principes SOLID, puis les principes de la programmation orientée données. Il vous permettra d'avoir une meilleure vision de ce qu'est la programmation orientée données, de comprendre ce qu'elle peut vous apporter dans l'organisation et la bonne modularisation de vos applications, afin de pouvoir l'appliquer à bon escient dans vos applications.

José

April 17, 2025
Tweet

More Decks by José

Other Decks in Programming

Transcript

  1. 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
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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?
  7. 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
  8. 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
  9. 4/17/2025 Copyright © 2025, Oracle and/or its affiliates 16 Fixing

    the Application / DB Relation DB FlightEntity (Hibernate) Business Module
  10. 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)
  11. 4/17/2025 Copyright © 2025, Oracle and/or its affiliates 18 Fixing

    the Application / DB Relation DB FlightEntity (Hibernate) Business Module <I> <DTO>
  12. 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
  13. 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