×
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.
Joe Pluta wrote:
And I'm not arguing about whether you should or shouldn't access member
variables; I prefer setters and getters myself. And while the getter is
pretty much a spelling issue (x = myvar *VS* x = getMyvar()), the setter is
a philosophical issue as well. Does "myvar = x" really indicate that you
are calling something as well as "setMyvar(x)"? That's up to you.
Well, I would have to both agree (with your thoughts in general), but
disagree with the importance of getters/setters vs. member access.
I had a situation where I re-engineered a class and using a getter &
setter saved my butt.
Originally the class had a String name field with a getter & setter.
I then reworked the class, based on new requirements, so the 'name' was
now coming from a enclosed object.
Because I was using a getter & setter, I was able to change the class
thusly:
--- old methods ---
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
--- new methods ---
private EnclosedObject encl;
public String getName() {
return encl.getName();
}
public void setName(String name) {
if (!name.equals(encl.getName()) {
encl = EnclosureFactory.getItem(name);
}
}
-------------------
Obviously that's an oversimplification ... and I didn't actually use the
setter (my objects are all created by factories) ... but I didn't have
to change anything else in my code to deal with a new implementation of
the items name.
david
As an Amazon Associate we earn from qualifying purchases.