
Until now you know the compilerinternal types long and
String, where String is just a simplification in the compiler language.
With the introduction of typechecking in the oop.library the way to methodeoverloading has been lite.
Valid types are all simple classnames like String,zahl,StringArray
aso. This results in a small problem. What if two packages have the same class names and should run at the same time?
In Java every program gets its own runtime system, the JVM. Under OOP4A this is not possible, because the
aos libraries are single named only. Two libs of the same name are not possible.
OOP4A could remove this problem, but that would cost extra cpu time every methodecall and would
be inperformand. Two same named classes are only valid if they offer the same interface to the world,
like to button classes in a gui system would do.
All classes are types by definition. An argumenttype has to given like this
class unkown
{
public test(long A,StringArray B)
{
...
}
}
The type long is an universal type. It takes all given arguments with out further checking. BTW:If you mean the class Long write Long, long is the internal variabletype and does not offer any methods. All types are casesensitive!
Als Überladung bezeichnet man die Eigenschaft einer Methode mehrere Implementierungen mit verschiedenen Argumentypen mitgeben zu können. Konkret bedeutet das, daß es in einer Klasse mehrere Methoden gleichen Namens geben kann. Die eigentlich auch gleiche Aufgaben versehen. Ein Beispiel macht dies deutlich: methodeoverloading means the characteristic of oop languages to have more than one methode with the same name, but different argumenttypes. These methods offer the same funcionality for different arguments:
class unkown
{
public test(long A,StringArray B)
{
...
}
public test(long A,String B)
{
...
}
}
ruft nun eine Klasse die Methode test der unbekannten Klasse auf, so kann Sie wahlweise einen String oder einen StringArray übergeben und erwarten das beides mal das gleiche passiert. If a class calls the methode test from class unkown, the oop.library will check the given arguments and searches for the correct methode to be used. The calling methode can use a String or a StringArray as Argument and both will work proper if the implemention has no errors :-).
class unkown
{
long A
public add(Integer B)
{
A=A+B.tolong() // this syntax is not yet supportet by the compiler.
}
public add(Long B)
{
A=A+B.getLong(B)
}
public add(Word B)
{
A=A+B.tolong(B)
}
}
Methodeoverloading makes it easier to group methods of the same functionality and to read sourcecodes. Instead of writing methodenames like "printLong()" "printStringArray()" you can just use the same name "print()" and it should be garantieed by the original coder that functionality stays the same. This is a coding style which has to be used by the programmer of the class. The compiler can`t garantee that.