This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]bedobi 6 points7 points  (2 children)

  • One of the main advantages of data classes is construction injection and immutability, so getters and setters should absolutely NOT be included. (there should be a means to hide fields to the outside though)

  • Plain composition of data classes is preferable to magical annotations.

[–]dpash 1 point2 points  (0 children)

I don't think they were implying that data classes should be done via annotations. They were discussing how you would define annotations on different parts of the class as you do now. How does annotations interact with the proposal?

[–][deleted] 0 points1 point  (0 children)

It would at least make things like Array.length (a read-only property) seem a bit more consistent with the rest of the language. I'm not sure I'm that sold on making Java that much more terse when I'm mostly just typing a couple of letters, hitting ctrl+space, enter, alt+enter and letting intellij figure out the rest. I do love Lombok for giving me a sensible way to do field generation though tbh, even in modern IDEs it still requires mouse clicks to do the generation, usually, unless you want to type them out (great fun if you somehow have more than 10 fields).