> Then what is overloading? And how is it different than overriding?
>
Overloading is where you have more than one method with the same name,
but different signatures. By signature I mean the number and type of
parameters as well as the return type. Different languages implement
different types of overloading.
Here is some information on Java in regard to overloading.
In Java, the same name can simultaneously be used for a local variable
or method parameter, different fields of the same object, and different
methods of the same object. Java uses context and type information to
determine the meaning of a name. For example, many Java programmers
would write the constructor for the class Cons above as follows:
Cons(Object first, List rest) {
this.first = first;
this.rest = rest;
}
In this example, the names first and rest each have two different
meanings. Java resolves potentially ambiguous uses of names by using the
innermost (most local) definition of the name. Hence, the prefix this.
is required to distinguish the first and rest fields of this from the
constructor parameters of the same name.
While the use of the same name for different kinds of program entities
is widely accepted as good programming practice, the use of one name for
several different fields or methods is more controversial. A Java
subclass B can introduce a field with exactly the same name n as a field
in its superclass A. The inherited field is not overridden (what would
overriding mean in this context?); it is merely ``shadowed''. When the
name n appears in a method of B, its meaning depends on the type of the
receiver. If the receiver is this, then the new field n introduced in B
is meant. But if the receiver has type A rather than B, then the old
field n introduced in A is meant. Warning: duplicate field names can be
the source of insidious program errors that are very difficult to
diagnose. For this reason, we strongly recommend against using them.
Duplicate method names are less controversial but can still be
dangerous. In a class, Java permits the same method name to be used for
different methods as long as their argument lists do not have the same
length and identical types. The practice of defining more than one
method in a class with same name is called method overloading. Java
resolves overloaded method names using the types of the argument
expressions. When the Java compiler encounters a method invocation
involving an overloaded method, it determines the types of the method
arguments and uses this information to select the "best" (most specific)
match from among the alternatives. If no best method exists, the program
is ill-formed and will be rejected by the Java compiler.
> : grumbles: Why isn't it documented? I know I had problems with
this
> during the beta cycle and I'd bet dollars to donuts I was told that
this
> couldn't be done. My problems could have been due to other issues,
> however. : shrugs:
>
Well if you ask me (you did), Macromedia is having a real problem with
both their documentation and their people giving out false information.
You have to understand that for many of CF people --including those from
Macromedia-- all this OO stuff is brand new.
-Matt
______________________________________________________________________
This list and all House of Fusion resources hosted by CFHosting.com. The place for
dependable ColdFusion Hosting.
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists