Skip to content

Add section to README.md comparing mapstruct with Java Records #3751

@earizon

Description

@earizon

Use case

Java Beans was designed with the first versions of Java around 1996. It looks to me that Java newcomers that have randomly read about Java development and Java Beans will randomly ignore the existence of the "alternative" Java Records. Also, beans are so "pervasive" in Java literature that there is a traction to continue using them by pure "inertia". A brief comparative in README.md can help clarify concepts. Both of them generate static safe code. Records are simpler to use and promote safe immutable data (data "dominates" over behavior), while Beans help in more complex scenarios for which the internal data structures and states will evolve over time (behavior "dominates" over data).
As of 2024-10 I guess the best approach is to use records for "simple data code". Fall back to MapStruct when Records just fall short.
Said otherwise, try to avoid people using Beans when Records "just work".

Generated Code

N/A

Possible workarounds

N/A.

MapStruct Version

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions