Coming back to the original post:

On 1 Jul., 20:07, MassH <[email protected]> wrote:
> First, it's clearly absurd to fill source code with boilerplate getter/
> setter code. Even if IDEs can auto-generate, it still has to be
> manually read/maintained.

Agree to that - I never understood why in C++ IDEs there is sooo much
code generated automatically.



> Libraries and frameworks like JPA/Facelets/Spring/etc should use
> explicit getter/setter methods if they exist and otherwise fallback on
> raw exposed instance variables. Some Java libraries already do that.

First thing that for me comes in mind: It then needs 2 checks - look
for the getter/setter and then call the instance variable. But what I
do not understand: There are properties also since VB and although
it's called "Property" it even needs a getter and a setter method. So
it is basically the same thing. I personally like the convention of
the getter and setter methods in Java. It offers more flexibility
because I can have multiple getters and setters (using different input
types for example) - although I know that this is not recommended.


> That way for the 99% case, you just use a plain instance variable and
> for the 1% case where you need non-trivial getter/setter logic you can
> write them. Also, you can change your code at any time without
> breaking compatibility.

In general I do not like to expose variables like this - as a plain
instance variable. I prefer the getters and setters (even in old VB
where both options where given either). So I do not have to reorganize
the code when I find out that on set of a particular property I want
to also change another internal variable or trigger a refresh or
whatever. I think there are other cases that produce more annoying
boilerplate code.

So I personally do not miss the properties, but I wonder why a
property declaration could not internally compile to the same result
as a classic getter and setter variant. Then it should also make no
difference in performance and you can write it just how you prefer it.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to