Is it possible to change an inherited access modifier in ActionScript 3? -
i'm working on project have ton of classes inheriting other classes inherit other classes , on. it's more complex should be, sucker abstraction.
anyway, @ times need alter getter/setter beingness public private. suppose it's not need, want cutting off things preset in kid classes, still need publicly accessible in parent classes.
so illustration be:
class base of operations { public function set label( value:string ):void{}; } class extends base of operations {} class b extends { public function b() { super(); this.label = "stuff"; } override public function set label( value:string ):void { //this setter should not publicly available since label should not possible alter in class } }
currently, doing 1 of 2 things in these cases:
override setter nil or set default value can still update/render/whatever throw error saying unavailable in classi've done searching , seems point beingness impossible, i've never found explicitly stated impossible. possible alter access modifier on inherited property/function?
it not possible, , should not be, because leads confusing , unpredictable class hierarchies. starters, if did that, break liskov substitution principle: super class should @ times replaceable derived classes. changing api prevent - , perchance lead runtime errors and/or inexplicable glitches, if programmer accidentally exchanged types.
if classes modeling have different behavior in such way create "hide" otherwise public api method, should not utilize inheritance - or perhaps in different way. describing, guess in larger part of hierarchy, should using composition instead of inheritance, anyway.
actionscript-3
No comments:
Post a Comment