By daniel
via cafe.elharo.com
Published: Jan 31 2007 / 18:08
The gates seem to be open for serious revisions to the Java language in Java 7. Thus it’s worth reviewing why some things are just flat out bad ideas for any language, because too many developers either never knew this or have forgotten it. First up: operator overloading:





Comments
boo_radley replied ago:
Reasoning seems to be "I can't imagine why this would be useful and I don't trust the people I work with who might use this". Not exactly solid logic there, champ. And for the examples (matrices, database records), I'd expect that when the operation couldn't apply, that the operation would -- wait for it -- throw an exception, or return some variation of NaN.
boo_radley replied ago:
Also, "Considered Harmful" is no longer clever.
sproketboy replied ago:
It *is* harmful in that it obfuscates the intent of the code.
What does
Customer c1 = getCustomer();
Customer c2 = getCustomer();
Customer c3 = c1 + c2;
mean?
boo_radley replied ago:
Are you dense? You don't have to apply operator overloading to every situation. What would it ever mean to "add two customers"? If it doesn't make sense conceptually, why would you expect it to make sense practically?
Voters For This Link (7)
Voters Against This Link (0)