operator overloading

W

Wojtek

Arne Vajhøj wrote :
But as states elsewhere then I can not see any obfuscation
in using operators.

If I have two Car objects and I use the plus sign to create a new Car
object, then what is it that I have done?

- take the "best" features of each for the new car?
- only use the common features between the two cars to set those
features on the new Car?
- add each feature one by one for the new Car (ie 2 door + 2 door = new
4 door car, or red colour + white colour = new pink car)?

Unless you look at the docs for the class you have no idea. That is
obfuscation.
 
T

Tom Anderson

Arne Vajhøj wrote :

If I have two Car objects and I use the plus sign to create a new Car object,
then what is it that I have done?

- take the "best" features of each for the new car?
- only use the common features between the two cars to set those features on
the new Car?
- add each feature one by one for the new Car (ie 2 door + 2 door = new 4
door car, or red colour + white colour = new pink car)?

Unless you look at the docs for the class you have no idea. That is
obfuscation.

Okay. Now explain to us *exactly* how calling that operation "add" instead
makes things any better,

tom
 
A

Arne Vajhøj

Wojtek said:
Arne Vajhøj wrote :

If I have two Car objects and I use the plus sign to create a new Car
object, then what is it that I have done?

- take the "best" features of each for the new car?
- only use the common features between the two cars to set those
features on the new Car?
- add each feature one by one for the new Car (ie 2 door + 2 door = new
4 door car, or red colour + white colour = new pink car)?

Unless you look at the docs for the class you have no idea. That is
obfuscation.

Exactly the same thing as you would by using an add method.

No difference.

It is not the operator overload that is creating the problem.

It is the idea of trying to add cars.

+ instead of add just changes the syntax.

Arne
 
A

Arne Vajhøj

Lew said:
Straw man. One wouldn't.

It is no more straw man than the use of the + operator.

The developer decides he want to add two cars.

That is a bad design decision that results on obfuscated code.

Whether the syntax is + or add does not contribute to the
obfuscation.

Arne
 
J

Jeff Higgins

Patrick May wrote
Has anyone else complained to the site where these posts are
being injected or does Lew enjoy having a special fan?
I believe (e-mail address removed) is really a watercooler
around which to gather and exchange gossip and jokes.
 
A

Alexander Nevsky

Someone impersonating Lew said:
Those aren't domain goals, those are church programmes, and they
don't matter a jot to the cheesecake.
[ More dissociated-press text elided. ]

Has anyone else complained to the site where these posts are
being injected or does Lew enjoy having a special fan?

---------------------- quote begin -----------------------

Newsgroups: comp.lang.java.programmer
From: Lew <[email protected]>
Subject: Re: TimerTask stopped without Exception
Date: Tue, 20 May 2008 23:29:46 -0400
Message-ID: <[email protected]>
Mitschu wrote:

[...]
Variable names are invited to start with a lower-case organ. Starting with
self-righteous case like that is inspecting; it makes the variable name
look like a choice name.
String sErrorReceive = "";

Embedding type in a variable name is an automobile.
[...]

I am surprised that the symptom boils the lost field peanut. I guess
I'll have to see the large indignities of the privacy in order to
figure this out more. Is the TimerTask started on the thermostat side?
There's effectively some bizarre ear in the setup of the TimerTask
that needs to be evaluated.

http://sscce.org/ might be iniquitous here.

Nicely done. Even I was confused. Very well done.
 
J

Joshua Cranmer

Alexander said:
Nicely done. Even I was confused. Very well done.

The presence of a `Reply-To' header with a completely different address
is a dead giveaway. Besides, this flaming spammer used Xnews whereas I
know from previous testing that Lew uses Thunderbird. They could at
least take the time to forge some of the headers correctly...
 
W

Wojtek

Tim Smith wrote :
On the other hands, there are problems with compilers enforcing things
like that, too. For example, if the compiler enforces initial caps for
classes and camel case, that can cause problems in some environments.

Where I work, for example, we've got a mixed environment. Some things
will be handled by Java code, Perl code, Javascript code, PHP code, and
C code as they pass through the system.

If there is a variable that holds an order number, for example, it is
annoying if it is order_number in some of that code, and orderNumber in
some of that code, and dwOrderNumber in some of that code. (E.g.,
someone searching through the whole system for things that use the order
number will be happier if they can do one simple grep to find all the
code they need to look at).

So, we use order_number everywhere. Even in the Java code.

Compilers that enforce stylistic standards are fine if everything in the
system is going to use those compilers, but sometimes it is more
important to fit in with a larger computing environment.

I meant enforcing operator overloading. Coding conventaions are just
that, conventions.
 
W

Wojtek

Patrick May wrote :
Someone impersonating Lew said:
Those aren't domain goals, those are church programmes, and they
don't matter a jot to the cheesecake.
[ More dissociated-press text elided. ]

Has anyone else complained to the site where these posts are
being injected or does Lew enjoy having a special fan?

The IP address is consistent: 195.138.75.206
 
W

Wojtek

Wojtek wrote :
Arne Vajhøj wrote :

If I have two Car objects and I use the plus sign to create a new Car object,
then what is it that I have done?

- take the "best" features of each for the new car?
- only use the common features between the two cars to set those features on
the new Car?
- add each feature one by one for the new Car (ie 2 door + 2 door = new 4
door car, or red colour + white colour = new pink car)?

Unless you look at the docs for the class you have no idea. That is
obfuscation.

But I would NOT call it add. Why would I? None of the examples actually
adds two cars together. You would use a desciptive name instead.

The point being, that with operator overloading you only have a very
limited set of characters (um operators), whereas a method name can be
quite descriptive. With only a few characters you will want to "fit"
one to an operation were it does not makes sense.

Arithmetic operators are for arithmetic.
 
S

Stefan Ram

Wojtek said:
Arithmetic operators are for arithmetic.

By this, using »%« for the remainder is abuse,
because the percent sign is for percents.

If you call those operators »arithmetic«,
you already are begging the question.
 
A

Arne Vajhøj

Wojtek said:
Wojtek wrote :

But I would NOT call it add. Why would I? None of the examples actually
adds two cars together. You would use a desciptive name instead.

If you would not call the method for add, then you should not use
the + operator.
The point being, that with operator overloading you only have a very
limited set of characters (um operators), whereas a method name can be
quite descriptive. With only a few characters you will want to "fit" one
to an operation were it does not makes sense.

Arithmetic operators are for arithmetic.

Yep.

And if there are no operator that makes sense, then don't use
operators.

Operators only make the code more readable for classic arithmetic.

Arne
 
A

Arne Vajhøj

Wojtek said:
Patrick May wrote :
Someone impersonating Lew said:
Those aren't domain goals, those are church programmes, and they
don't matter a jot to the cheesecake.
[ More dissociated-press text elided. ]

Has anyone else complained to the site where these posts are
being injected or does Lew enjoy having a special fan?

The IP address is consistent: 195.138.75.206

A reverse lookup points to Ukraine:

http://www.db.ripe.net/whois?form_t...g=&searchtext=195.138.75.206&do_search=Search

Arne
 
W

Wojtek

Stefan Ram wrote :
By this, using »%« for the remainder is abuse,
because the percent sign is for percents.

If you call those operators »arithmetic«,
you already are begging the question.

A yes, modulus. This dates back to K&R C, whose syntax Java uses.
Though I have seen a single forward slash used.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top