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



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.  I guess I'm sort of torn because I can make a 
case for each method.  Obviously, using
the getter/setters creates additional overhead *but* using them within the 
class seems to be more roboust.

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

Here what I mean....

Let's say I have a right justification method (much like Aaron's, actually ;-) 
)  and for a certain type of data,   the
data is expected to be 8 characters.  So.....

<code>
public String rightJustify(String s, int length) {
        (insert your favorite code here)
}
</code>

and then

<code>
public String rightJustify(String s) {
        return rightJustify(s,8);
}
</code>

Any comments on either technique would be welcome...  I'd like to some 
different points of view to help me decide the
merits of these techniques....

thanks

dan


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.