Carry out a project Join us
Data Oriented Programm

Data-Oriented Programming (DOP)

13-06-2024 Expertise

Java’s Latest Tools: Empowering Data Management

Data-Oriented Programming was a focal point of discussion at the Tech Hub Conference 2023 in Porto and remains a pertinent topic aligned with Apside’s expertise. This programming paradigm serves as a structured approach to managing the complexity inherent in program development settings. It is essential to note that Data-Oriented Programming does not seek to supplant Object-Oriented Programming; rather, both paradigms often complement each other. Object-Oriented Programming languages like Java or C# were initially developed during an era dominated by monolithic applications, necessitating the management of model state and behavior.


In contemporary application development, the trend is towards the decomposition of applications into smaller, interoperable services, which are either consumed by other services or interact directly with the front-end. These services typically handle requests from external sources, such as HTTP requests, which often carry untyped payloads like JSON, XML, or YAML. However, it is generally impractical for services to directly manipulate data in these raw formats. Instead, representing data in more structured forms, such as integers for numbers, LocalDateTime classes for dates or collections for lists, proves to be more intuitive and manageable. Moreover, data validation, at least prior to processing, is a fundamental practice to ensure data integrity and reliability.


Unlocking Efficiency with Java Records and Sealed Classes

In summarizing the implementation guidelines for data-oriented programming (DOP), Nicolai Parlog, drawing from Brian Goetz’s article, presents the following guiding principles:


  1. Modeling Data: Records should strictly model data, each representing a singular entity with clear and descriptive component names. Choices within the data model, such as alternative scenarios, should be encapsulated using sealed classes, with each alternative modeled by a distinct record. Behavior within record classes should be confined to operations derived directly from the data itself, such as formatting.
  2. Immutability of Data: Data should be immutable to ensure stability and consistency. Mutable fields within objects introduce ambiguity and can lead to unexpected changes in the data. Records provide some level of immutability, but adherence to strict immutability requires discipline to prevent mutable states from compromising data integrity.
  3. Boundary Validation: Prior to integrating data into the system, it should undergo validation to ensure its validity. This validation process can occur within the record constructor if it applies universally, or it can be performed at the system’s boundary, where data is received from external sources.
  4. Eliminating Illegal States: Utilizing records and sealed types facilitates the modeling of domains in a manner that renders erroneous states unrepresentable. This approach is preferable to constantly checking for validity, as it prevents invalid data from being modeled altogether. Immutability and stringent modeling techniques help eliminate common sources of errors in programs.


These principles are also elaborated upon by Yehonathan Sharvit in his blog, where he defines five complementary principles:


  • Code-Data Separation: Maintain a clear distinction between code and data.
  • Generic Entity  : Model entities using generic data structures.
  • Immutable Data: Enforce the immutability of data to ensure consistency and stability.
  • Value-based Comparability: Data should be comparable in value.
  • Literal Data Representation: Data should possess a literal representation for clarity and ease of understanding.


Hidden Benefits: Testing and Performance in Modern Java Programming

The latest iterations of Java introduce several valuable tools, including:

  • Record Classes: These serve as transparent containers for immutable data. Their benefits include enhanced compiler understanding of internal structures, tighter coupling of APIs to internal representations, and a significant reduction in verbosity. An illustrative example of their usage is provided.
Data-Oriented Programming (DOP)
  • Sealed Classes: These types restrict inheritance, permitting only specific subtypes. Their advantages encompass clear communication of developer intentions, compiler-enabled exhaustiveness checks, and facilitation of algebraic data types (ADTs). An example demonstrates how the implementation of data-oriented programming (DOP) utilizing these tools yields programs that are more concise, readable, and reliable.
Data-Oriented Programming (DOP)

Moreover, leveraging these Java features offers two additional, albeit less obvious, advantages: enhanced testability and performance. Simplified, well-defined data inputs and outputs streamline the testing process, particularly facilitating generative testing, which often proves more effective at detecting bugs than manual test case creation. Furthermore, Java Records outperform traditional classes in terms of memory utilization and performance, owing to their immutable nature, JVM implementation specifics, and optimization techniques such as compacting and inlining employed by the JVM for classes marked as records.



1 – Data Oriented Programming in Java – InfoQ

2 – Data-Oriented Programming (

3 – Data Oriented Programming: Table of Contents | Yehonathan Sharvit (

4 – Data-Oriented Programming in Java (

5 – Java Pattern: Algebraic Data Types · Garciat

The author
Diogo Figueira
Tech Lead

Diogo is the Technical Leader at our Aveiro agency. With a passion for new technologies and a love for sharing knowledge, he is dedicated to fostering a collaborative environment. Diogo firmly believes that teamwork is the cornerstone of his team’s success and is essential for achieving the company’s goals.


The personal data collected by Apside, in the capacity of data controller, from this form is required to process your request for information. It is sent to our Communications Department and our sales teams. This includes your surname, first name, phone number and email address. The conditions applicable to their processing are detailed in our confidentiality policy.

As required by the RGPD, you have the right to information, access, opposition, correction, limitation, deletion and portability of your data, which you may exercise by contacting our Data Protection Officer:

Either by email: [email protected]

Or by post: Apside – 4 place des Ailes – 92100 Boulogne Billancourt)

This Website is also protected by reCAPTCHA. By giving your consent to process the form, you also accept Google’s Terms of Service and Privacy Policy.