Re:Java: Missing Features
by jonathankoren on Thursday November 26, 2015 @02:11AM
(#10631705)
If there's no logic in the getter and setters, just make the properties public.
[ Parent
| on HN ]
That works until you want to add logic without breaking existing interfaces.
Or until you need to use them in beans and the like.
Play!Framework 2 for Java is awesome in this matter. You write public members, but at compilation it transforms them into private members with getters and setters (if not final). It means if you write the setter, it overrides the default one.
Lombok does the same ;)
But then you're using Lombok...
Re:Java: Missing Features
by dfullarton on Thursday November 26, 2015 @07:32AM
(#10632663)
Can you clarify? I've heard similar negative feelings from devs. What's wrong with lombok?
Re:Java: Missing Features
by ossreality on Thursday November 26, 2015 @02:17AM
(#10631720)
Huh? Then they're just fields and not properties, maybe I'm misunderstanding what you're trying to say. And there are numerous reasons that Properties are preferable to Fields.
Unless someone else can help me, I think this is really bad advice for a C# developer.
Re:Java: Missing Features
by jonathankoren on Saturday November 28, 2015 @01:17AM
(#10640233)
>Huh? Then they're just fields and not properties
Nomenclature schmomenclature.
They're variables with object scope.