× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



From: Walden H. Leverich


Does "myvar = x" really indicate that you
are calling something as well as "setMyvar(x)"?

To my way of thinking (again opinion and style) getter/setter "methods"
are extremely lightweight, where method calls may not be.

I'm not talking about weight. I agree with you entirely on that issue; JIT
compilers ought to handle any issues there.


What I do like is that if I have to add a second parameter to the
setter, I already have the code in place and I just have to add
the variable, whereas if I have to change the
"myvar = x" syntax, it's more of a change.

OK, so actually, "setter" and "getter" are a convention thing in Java,
not a language thing? Correct? Does Java have "properties" as part of
the language spec?

Correct. setMyvar and getMyvar ("isMyvar" in the case of a Boolean) are
conventions. However, they're conventions that are followed by all IDEs and
indeed are required by certain J2EE functions. If you DON'T name your
getters and setters properly, you will probably cause yourself some extra
complexity down the road.

And no, there is no property concept in Java. You have classes, and your
classes have variables. Static and instance, public and private. Very
basic OO stuff.


In the .net mvar=x syntax there is _no way_ you could add a second parm
to a setter or getter.

That's my issue. Because of this, the syntax to set a variable using only
one parameter is completely different than the syntax you use when you need
more than one parameter. And all that to hide the fact that you're actually
calling a setter.


If you wanted to add a "second" parm to your you're create a method that
did what you wanted.

And then I'd have to find all the instances where "myVar = x" and change
them to "setMyvar(x,y)". Nothing horrible, but hopefully you can see where
my personal preference isn't entirely unreasonable.

Anywho, I think we've really addressed the issue. The inherent setter and
getter for properties is a convenience and I think it's fine for those who
like them, but there's nothing particularly wrong with explicit setter and
getter methods, either (that is, unless you get entirely CompSci nutty and
call them "accessors" and "mutators", at which time you have to go eat at
the ultra-nerd table).

Joe


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.