[917] in java-interest

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

Re: overloading of operators

daemon@ATHENA.MIT.EDU (Tako Schotanus)
Tue Aug 15 16:10:12 1995

Date: Tue, 15 Aug 95 18:26:07 +0200
To: Thomas.Ball@Eng.Sun.COM (Thomas Ball)
From: Tako Schotanus <Tako.Schotanus@bouw.tno.nl>
Cc: java-interest@java.Eng.Sun.COM

At 08:51 15-08-95 -0700, Thomas Ball wrote:
>>  I don't understand you guys at all! It's not as if *your* programs would be
>>  any worse off for just having a feature built into the language!
>>  And as for other people's programs, you're basically telling them "you can't
>>  use that feature because I don't like it".
>
>It's apparent you have never had to support someone else's code.  Using
>operator-overloading, with the possible exception of new numerical
>types, increases the cost of maintaining and supporting the code,
>because it requires that you potentially learn a new language with each
>class.  If you want to write write-only code, use Forth (*that* statement
>should start a religious war :-). 

But you agree that your "possible exception" would be a valid one?


>>  So for me: *I* like operator-overloading, I think that if you use it in a
>>  controlled way it can make your code more elegant, but that's a personal
>>  opinion for sure. But I might not be alone, I might be working for a
>>  company where it's "policy" to write code like that, and because everybody
>>  does it you don't have to worry that much about misinterpreting each others
>>  code.
>
>It's a great waste of time:  what's the "right" use of the '+' operator
>in a graphics image?  You can spend many otherwise fruitful days arguing
>with your co-workers that it should mean and'ing the bits of the two
>images, while they staunchly argue it means appending the two images.
>It avoids real work, but what problem does it ultimately solve?

*grin*

But isn't that what documentation is supposed to be for? I agree that op-overl.
could be abused but so can a lot of things. Don't we all get taught to use
understandable variable- and function-names? But I still encounter things in
*my* co-workers code I don't understand because they decided to use xyz123
as a name because they were busy implementing and didn't have time to think
of something better.

I think the same holds true for op-overl.: if you're on a development team you
could make an agreement that op-overl. should only be used for numerical types
or anything mathmatical or that if you add two images you AND them and not
append them.
If I write a function called AddImage() what do I mean? ANDing or appending?
I could do two things: rename to AndImage() and AppendImage() (but I'm sure
people would come up with arguments why those names aren't good either) or
put it into the documentation (paper, on-line as well as in-line) what it
does exactly.

>
>One thing few people have noticed is how Microsoft's Visual C++ team is
>getting away with using a subset of the language.  The MFC is probably
>one of the best Windows C++ frameworks, and they don't use any overloading
>in their 200+ classes.  One reason they've stated they don't is that the
>framework would be used by thousands of developers, and they wanted it to
>be as easy-to-use as possible.  If Java is to remain an easy-to-use
>language, we should heed their advice.

Hmmm, I don't know how many of the MFC have anything to do with mathmatics (or other
things that could be added or substracted in a logical way) but I can understand
why they wouldn't want to explain to people what it means to add two windows
together! But if there are a lot of classes that could possibly benefit from
op-overl. and they didn't because they think it would make it difficult for
others to understand.... well I could buy that (though I would still like to
know why exactly ;)

>
>>  As for the fact that somebody else might find it difficult to understand my code,
>>  well to be honest (as long as I don't publish the code ;) I don't give a
>>  .......... (fill in your favourite rodent's backside).
>
>I hope we never work together.  You sound like a nice, intelligent person,

Thanks ;)

>but I'd sure hate to be on a team that has a tight schedule with you.  Code
>is shared by the development team -- what happens if you get hit by a bus?  

True, (although I must say everyone says I write very readable code, but then
again, I don't use op-overl. myself either! =)
But seriously, it's not always that you work with a team, so I still think
that for some things op-overl. could be useful. If you and your time think
or know from experience that you can get into trouble meeting deadlines or
tracing bugs or whatever when you use op-verl. can't you decide for yourself
that you don't want to use op-overl.??

>Someone needs to design, implement, test, and support these features.  The
>Java team is small, so that means other features will have to be cut to
>support this one.  What are you willing to give up?

Well, I think the remark below and at the beginning says it all, doesn't it? ;)
If they decide not to put it in I won't lose even one night's sleep over it,
but it would irritate me if it was done because of prejudice, personal preferences,
or unsound thinking.

>>  (Compelling reasons could be: performance problems even for programs NOT
>>  using the feature or even just that the Sun-people think it's too much work :)

>I strongly recommend you (and everyone else) read the book, Writing Solid
>Code, by Steve Macquire from Microsoft Press.

And what are his reasons for not using op-overl.?? (really interested!)

- Tako
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
_/               Tako Schotanus, TNO Bouwinformatica                    _/
_/   work: Lange Kleiweg 5, 2288 GH, Rijswijk, NL, tel: +31-15-842393   _/
_/       home: van Hasseltlaan 352, 2625 HZ, Delft, The Netherlands     _/
_/     E-mail: sst@bouw.tno.nl - URL: http://huizen.dds.nl/~quintess    _/
_/ Never let a dictator rule with peace; let peace rule like a dictator _/
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

-
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