meteor-astronomy
meteor-astronomy copied to clipboard
delete field on subtype?
I might just be blind, but is there a way when defining an inherited class, to specify that a field on the parent does not apply on the child?
In this way, if a subclass needs the majority of the fields of th parent, it can have them, but it can also eliminate a few that aren't needed.
I was thinking this may simplify my decision making process sometimes when defining a tree of inherited objects. I will sometimes regret making an object a subclass because it inherit some 'cruft' but at the same time I don't want to make a bunch of non-related 'parallel' objects and functionality.
Generally this wouldn't be a big issue, but imagine the case where you have some code that does introspection on some object and iterates across the fields that are present. In this case, it would be handy to exclude some.
Hey, by definition it would just break inheritance model. In classical inheritance model a child always inherits all the parent's properties. If you need that feature, it probably means that you shouldn't inherit or just don't put such a field in the parent, or mark it as nullable/not-required. The properly will still be there but just empty. I would rather not use inheritance in the first place, but everything depends on the use-case.