Anyone who has programmed with actionscript 3.0 has most certainly noticed its lack of support for private constructors and abstract classes. There are ways to work around these flaws, like throwing errors from methods which should be abstract, but these work arounds are annoying and not very elegant. (Throwing an error from a method that should be abstract is a run-time check, not compile-time, which can lead to a lot of frustration).
I know actionscript 3.0 follows the current ECMAscript standard and this is the reason for its lack of private constructors, but what about abstract classes, are they not in the ECMAscript standard eather?
I guess the more specific question is why does ECMAscript standard not support private constructors? Is it something that can be look forward to in the future?
I have been wondering this for quit sometime, any insight will be much appreciated.
private constructors and abstract classes are not ‘good OOP elements’. they’re nice hacks originated in C++. in more dynamic languages they’re usually not needed.
abstract classes in particular are totally unneeded, since you don’t have to declare the interface in the ancestor to comply with an interface. in fact, you don’t even have to inherit from a common ancestor to use some polymorphism.
i’m not saying that AS is better without something like that; rather that you should think in the language you’re using, not trying to translate from whatever you’re used to.