Catch up on stories from the past week (and beyond) at the Slashdot story archive

 



Forgot your password?
typodupeerror
×
Java Programming

Overloading and Smooth Operators 75

An anonymous reader writes "IBM DeveloperWorks has an interesting article on operator ad hoc polymorphism (operator overloading for the uninitiated). With the increase in Java popularity and their banning of operator overloading (among other things) the author decides to show some of the great benefits that operator overloading can bring, as long as it is served with a 'healthy dose of caution.'"
This discussion has been archived. No new comments can be posted.

Overloading and Smooth Operators

Comments Filter:
  • Re:Useful? Doubtful. (Score:3, Interesting)

    by bluGill ( 862 ) on Wednesday October 26, 2005 @03:51PM (#13883547)

    Will the use of overloading operators... *) reduce development time? *) reduce the number of bugs? *) improve maintainability?

    If the answer is yes to the above (This is an all or nothing test), then use them, if not don't use them.

    There is a good reason that most examples of operator overloading are complex numbers - using overloaded operators for complex numbers reduces development time, reduces the number of bugs, and improves maintainability.

    There is a good reason examples of operator overloading never use shapes. While I can design an shape interface where
    circle + square
    is legal, and gives some useful result. However this will increase development time, increase the number of bugs, and reduce maintainability. Therefore anyone use overloads operators for shape classes is a fool.

    Operator overloading is often abused. I rarely find it useful to overload operators, but in those few cases where I overload an operator I make my code better.

Those who can, do; those who can't, write. Those who can't write work for the Bell Labs Record.

Working...