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

Reconsider component inheritance #293

Open
klafbang opened this issue Oct 28, 2024 · 0 comments
Open

Reconsider component inheritance #293

klafbang opened this issue Oct 28, 2024 · 0 comments

Comments

@klafbang
Copy link
Collaborator

klafbang commented Oct 28, 2024

Inheritance should not be used for code sharing, instead use composition. This is a generic principle (https://en.wikipedia.org/wiki/Composition_over_inheritance) but in particular true for Angular components.

Now all/most components participate in an inheritance hierarchy. They do this by declaring abstract components. This is a code small and should be avoided.

If truly necessary to share functionality, instead create a service injecting what is needed, then inject that into components. This will also make the code shorter as we no longer have to autowire a ton of unnecessary services into all components to pass to the parent.

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

No branches or pull requests

1 participant