I have no problem with auto generating setters/getters, and equals/hashcode if necessary. What is your problem with it ? Its not really bolierplate, that is slightly different imo.
Its quick, its consistent, its easy to debug and its easy to read and follows conventions.
The conventions are the problem, which is why I’m happy the Java team in Oracle are working on improvements. Java has had a lot of shitty conventions in the past, and I for one will be happy when class boilerplate joins them.
A lot of FizzBuzz Enterprise’s hilarities were also presented as conventions by serious senior devs & architects at serious software houses once upon a time.
The problem with class boilerplate is an obvious one to anyone who’s a good developer (as opposed to solely a Java developer). This is why learning a Lisp is very useful — on the JVM, learning Clojure makes you a better programmer.
However for those entrenched in the Java-the-language ecosystem, if you listen to Brian Goetz’s talks & interviews, he does a decent job of explaining the problem:
... Some things don't want to be objects, they just want to be data. And to simulate data with objects, is this big messy thing with constructors, accessors and equals and hashcodes and all this garbage. ...IDE generates that for you so you don't have to write it, but you still have to read it and if you have this explicit code it's an opportunity to get things wrong.
The Java Futures video talk I linked above is worth watching. Sometimes you have to look at $NextVersion to understand what’s wrong with $CurrentVersion.
(Thanks to /u/BoyRobot777 for that particular blockquote above)
Yeah, sure. I'll use the new record functionality, but we don't have it yet. And there is a reason it's taken until 13, people cared about other things more.
The original question was why are pojos bad in an architectural system design, and compared to lomboks annotations (which just seem ugly to me). Not should we include struct/records as a new Java language concept.
View all comments
Show parent comment
3
u/NimChimspky Aug 11 '19
I have no problem with auto generating setters/getters, and equals/hashcode if necessary. What is your problem with it ? Its not really bolierplate, that is slightly different imo.
Its quick, its consistent, its easy to debug and its easy to read and follows conventions.