JIN
1 min readOct 13, 2024

--

Well documents.

The document introduces two programming paradigms, allowing readers to quickly understand the characteristics of DOP and OOP through a comparison of key differences.

When implementing DDD value objects as Java records, we can use data-oriented programming. When constructing entities as Java classes with an identifier and a record, we can use object-oriented programming to encapsulates the behavior associated with the entity while the record holds the data related to the entity.

Java records is data which is immutable.

Java classes - define the behavior of the entity. For example, if the entity is a "Medium reader", the methods might be likepost, commentpost, etc

The data-related aspects are handled by Java records. The behavior-related aspects are handled by Java classes.

Take example of banking application.

Account (Entities) - methods such as deposits, withdraw, and checkbalance

Money (value object) - a record that hold the amount of money.

branch (Value object) - hold the data such as branch name, branch code, branch address, etc

--

--

Responses (1)