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

Composition over inheritence #5

Open
devinrader opened this issue Oct 7, 2014 · 2 comments
Open

Composition over inheritence #5

devinrader opened this issue Oct 7, 2014 · 2 comments
Labels

Comments

@devinrader
Copy link
Collaborator

The library currently forces me to inherit all of my models from Resource. Can we find a way to switch this to a composition model instead?

@biscuit314
Copy link
Collaborator

I'm open to suggestions. Here's why I haven't done it yet:

  • It's easier in the formatter to ask "What's your type" than "Do you contain all of the properties I need you to contain" This is a particular problem wrestling between a single resource and a list of resources (which I'm still struggling with).
  • I want to encourage creating a pure resource model, not painting a resource model over an entity model. I am working on some examples that illustrate this. If this is the right approach (and it may not be) then there is no need for multiple inheritance or mix-in classes.
  • Before really thinking through the resource model, I want to get CJ working, then maybe even Siren. This exercise is really informing me on how leaky the abstraction needs to be to be truly generic over multiple media types. Once that is done, I will do a heavy re-think over the programming model this library enables.

An alternate in the meantime: if you already have a class that inherits from something else, that class can implement IResource and it will work the same as inheriting from Resource. You just have to instantiate the Relations property yourself.

@devinrader
Copy link
Collaborator Author

Its entirely possible that just using the interface gets me where I would like to be. I'll have a go it it when I get a chance.

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

No branches or pull requests

2 participants