Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete field on subtype? #719

Open
meecect opened this issue Jan 4, 2021 · 1 comment
Open

delete field on subtype? #719

meecect opened this issue Jan 4, 2021 · 1 comment

Comments

@meecect
Copy link

meecect commented Jan 4, 2021

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.

@lukejagodzinski
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants