[1024] in java-interest

home help back first fref pref prev next nref lref last post

Re: overloading of operators

daemon@ATHENA.MIT.EDU (Kevin Krom)
Thu Aug 17 01:32:39 1995

Date: Wed, 16 Aug 1995 10:01:47 +0500
From: krom@cgi.com (Kevin Krom)
To: java-interest@java.sun.com

The point I have been trying to make is that *any* language feature can be
abused by poor programmers.  Poor programmers write poor programs.  There is
nothing inherent to an overloaded operator that makes it harder to understand,
implement, or maintain than an equivalent function/method.

The flip side, of course, is that good programmers write programs that are well documented, maintainable, and easy to understand.  As a good programmer, use
operators where they make sense, and use descriptive function names everywhere
else (and yet another assualt on the String class -- why use the abbreviation
"Concat" instead of "Concatenate"?).

Unlike some of the other operator overloading proponents, I am not going to
waffle and say that they should only be used on numeric types.  Be sensible
and consistent in your usage.  For example "+" can be used for any operation
that concatenates, appends, or combines.  Strings, lists, arrays, images,
sounds, animations, documents... in essence, any objects that can be used
in combinations.  Other operators can be useful in general applications --
how about "&" (bitwise AND) as a generic filter operation (say, in an image
class...)

As far as maintaining code written by others, I thought that's why code
walkthroughs were created.  If the code isn't easy for the reviewers to follow,
it should caught then.  Similar to above, code written by a poor programmer
(or at least one using poor programming practices) is going to be difficult
to maintain, regardless of whether or not operator overloading was used.

The short version is: just because *you* don't like operator overloading, don't
attempt to deny the rest of us who see added value in operator overloading this
feature in the language
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post