I have encountered a behavior that *might* be a bug but I wanted to
get some input from folks before submitting it... Perhaps there is a
simple workaround?

One of the major reasons to use Object Oriented Programming is because
we can create abstract, generalized super classes and then create
concrete subclasses that expect and create more specificity.
(Polymorphism)

The way this is implemented in Java (and other strongly-typed
languages) is by using Method Overloading and Method Overriding. A
subclass simply redefines a method with the same name as a superclass
but implements a more specific argument and/or return type.

In ActionScript, we don't get method overloading - Which is fine by me
as it can often lead to a lot of verbose code and probably a
bloated/slower runtime environment since we would then need runtime
type-checking.

When using the Flash IDE, I can write an abstract superclass that
expects or returns a more generic object (Let's say "Object" for
example). Then I can create a subclass that expects a more specific
implementation of that object. (Let's say "ConcreteObject") This would
be known as a simple "Method Override"...

This fails in Flex because the compiler complains that the subclass
must implement the *same* method signature that is found in the super
class. For a good example, try extending Array and overriding one of
it's built-in methods but accept or return a custom object rather than
Object Object.

That behavior is fine with me - IF - we are ALSO given the ability to
"overload" methods, but without that capability, this problem renders
the Flex Compiler pretty useless for real, Object-Oriented
architecture because it fundamentally prevents polymorphism.

Hasn't anyone else run into this?

Please forgive me If this has already come up, I would be glad to have
a link to some related conversation if you know of one and I would be
even happier if there is a simple flag or workaround to make this
work.


Thanks,

Luke Bayes
www.asunit.com





Reply via email to