You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
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.
The text was updated successfully, but these errors were encountered: