In both examples, we have moved the business logic from the client(s) to the data class, which starts to acquire responsibilities. =>
- we have much simpler clients, /*understanbale, evolvable */
- we do not have dupicate code,
- we are reducing the essential coupling of classes (clients use only a small part of the public API of the service provider)
=>
we can evolve with more ease and we can test better
CAUTION: When you move methods from the client classes to the Data Container, you will need to introduce parameters to make the moved method to work
Data is plain old data (output of a parser, data from a database, ...)
See also
https://blogs.oracle.com/javamagazine/records-come-to-java
https://projectlombok.org/features/Data
In both examples, we have moved the business logic from the client(s) to the data class, which starts to acquire responsibilities. =>
=>
we can evolve with more ease and we can test better
CAUTION: When you move methods from the client classes to the Data Container, you will need to introduce parameters to make the moved method to work
Data is plain old data (output of a parser, data from a database, ...)
See also
https://blogs.oracle.com/javamagazine/records-come-to-java
https://projectlombok.org/features/Data