GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add section to README.md comparing mapstruct with Java Records · Issue #3751 · mapstruct/mapstruct

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

New issue
Copy link
New issue
Copy link
Closed
#3762
Closed
Add section to README.md comparing mapstruct with Java Records#3751
#3762
Copy link
Labels
documentation
Milestone
1.6.3

Description

@earizon
earizon
opened on Oct 28, 2024
Issue body actions

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

Activity

  1. filiphr
    added
    documentation
    on Nov 3, 2024
  2. filiphr
    modified the milestones: 1.7.0, 1.6.3 on Nov 3, 2024
  3. filiphr commented on Nov 3, 2024

    @filiphr
    filiphr
    on Nov 3, 2024
    Member
    More actions

    That's a good point @earizon. I'll try to work a bit on the wording.

    MapStruct in the end is for data mapping. Whether your data is done with beans, DTOs, builders, records does not make difference to MapStruct.

    Records are simpler to use and promote safe immutable data (data "dominates" over behavior),

    Here I am also a bit vary as the data is immutable if the passed objects are immutable.

    e.g.

    record Customer(String name, List<Address> addresses)

    The example above is not immutable as List on its own is mutable.

  4. filiphr
    added a commit that references this issue on Nov 9, 2024

    mapstruct#3751 Improve readme to include support for Java 16+ records

    0a53c5c
  5. filiphr commented on Nov 9, 2024

    @filiphr
    filiphr
    on Nov 9, 2024
    Member
    More actions

    @earizon does #3762 make sense to you?

  6. filiphr
    closed this as completedin #3762on Nov 9, 2024
  7. filiphr
    added a commit that references this issue on Nov 9, 2024

    #3751 Improve readme to include support for Java 16+ records

    efdf435
  8. earizon commented on Nov 11, 2024

    @earizon
    earizon
    on Nov 11, 2024
    Author
    More actions

    @earizon does #3762 make sense to you?

    Yes it does! I owe you a coffee!

    Reacted by Filip Hrisafov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentation

    Type

    No type

    Projects

    No projects

      Milestone

      • 1.6.3

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.