× 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.



First, a little background, I program in C++ and haven't really started in
Java yet.

For your first question: In my own methods in C++ objects I change the class
variables directly inside the class rather than using my Get/Set methods.
Primarily because it is easier to maintain because someone knows what I'm
doing when I say:
MyInt = MyVar;
inside a method, but if I say:
SetInt( MyVar );
I'm going to wonder why I didn't just use the assignment and have a look in
SetInt just to see that it's only doing an assignment.

If, on the other hand, there was validity checking in the Set method then I
would use the Set method instead if I wanted that validity checking in the
method I was coding.

For your second question: I've done that quite a bit in different languages
where it is allowed and I like it.  That is, creating a generic method and
then creating overrides.

Regards,

Jim Langston

-----Original Message-----
From: Eyers, Daniel [mailto:daniel.eyers@honeywell.com]

Something I've been thinking about....

For a class that has instance variables, I tend to use private variables and
getter/setter methods for access. In the
class itself, however, I'm wondering which makes sense, to use the
getter/setters within the class itself, *or* to
access the variables directly. ...
<SNIP>

Additionally, I tend to consider creating a generic method to add a certain
functionality, then create methods that
overload by adding (or removing) parameters.

<SNIP>


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.