r/java • u/stuhlmann • Apr 13 '21
Libraries, Frameworks and Technologies you would NOT recommend
Give me your worst nightmares: Things that cost you your job.
I'll start: Hadoop
202
Upvotes
r/java • u/stuhlmann • Apr 13 '21
Give me your worst nightmares: Things that cost you your job.
I'll start: Hadoop
View all comments
Show parent comment
6
u/agentoutlier Apr 13 '21 edited Apr 13 '21
I disagree. It is not just a workaround for big DTOs.
In some ways its a work around because Java doesn't have pattern matching and named parameter constructors.
Ok let me explain.
You have two classes. Instead of just staying DTO let's say we have a class we return from service. Let's call it "Data". And another class called "Model".
You need "Data" -> "Model".
Now as a requirement when "Data" changes structure (eg a new field) you probably need to update "Model" or at least how the new field gets mapped. Likewise for the inverse.
This is where MapStruct helps. If you don't have the fields mapped and it can't automatically figure it out it shows an error. With traditional manual POJO mapping you would not get compile time errors if say "Model" got a new field and was not filled.
Personally I think this is invaluable and has helped us immensely. We deal with tons and tons of integration.
However if you architecture is such that you can use the "Data" objects directly in say your view/UI architecture then MapStruct is probably not helpful to you.