Overloading
m (Reverted edits by Ebybymic (Talk); changed back to last version by BenMcDonald) |
|||
(3 intermediate revisions by 3 users not shown) | |||
Line 6: | Line 6: | ||
[[Image:overloading.JPG]] | [[Image:overloading.JPG]] | ||
+ | |||
+ | ==The problem with overloading== | ||
+ | Method overloading can create hard to read code as method arguments are hidden to the reader. It is not clear from reading code that method arguments are being overloaded and discovering overloaded methods requires searching though an object's definition. | ||
+ | |||
+ | Consider [[Option-operand separation]] instead. | ||
+ | |||
+ | {{Nomenclature}} | ||
[[Category: Nomenclature]] | [[Category: Nomenclature]] |
Latest revision as of 03:23, 25 November 2010
Overloading occurs when several methods have the same names with different method signatures. In the example above, the same method speak can have 2 different forms or method signatures. The first one only includes a single parameter word, the second one includes 2 parameters: word and language.
Overloading lets two functions/method share a name if they differ in the number and or the type of arguments; two functions may not differ only in their return type
The problem with overloading
Method overloading can create hard to read code as method arguments are hidden to the reader. It is not clear from reading code that method arguments are being overloaded and discovering overloaded methods requires searching though an object's definition.
Consider Option-operand separation instead.
Nomenclature | |
---|---|
Techniques: Abstraction | Aggregation versus Composition | Association versus Dependency | Coupling | Encapsulation | Information hiding | Inheritance | Multiple Inheritance | Overloading | Polymorphism
Features: Abstract class | Class versus Object | Component versus Module | Instance | Interface | Method | Package versus Namespace | Superclass | Subclass |