-
Notifications
You must be signed in to change notification settings - Fork 41
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
DISCUSSION: Dependency Inversion Principle Violation #29
Comments
@mtoncic I'm also leaning towards Between @mtoncic what are your thoughts on this? |
You can materialise an IEnumerable at anytime. However if you materialize a large amount of data in a controller I think is bad design.
For example using IQueryable allows for the passing of the query to the database engine. ToList blocks this behaviour |
Good points you've made. It depends mostly on the use cases that we're going to have. Why I brought IReadonly in the first place - when I request something from a service/API and it returns me results it makes sense to me NOT to mutate that but if there are some changes to be made these changes should produce another result. I don't see really a problem with deferred execution. Once you need to do some processing you'll materialize it. |
Hi all,
Abstractions should not depend on details.
Here we're violating this by using the concrete implementation of the collection interface.
If in the concrete implementations we change List to something else that implements the same interface our contract would need to change. So we are strongly coupled.
For instance:
Instead we should move to the abstraction and in the underlying implementations, if we need some concrete implementation, we can use it.
One reasonable choice would be IEnumerable. That's okay.
But, on the other side I believe that the data that we consume from other services/APIs should not be changeable.
Therefore we could use IReadOnlyCollection and enforce that collections are not changed.
I know that we can again change the underlying props of the collection objects but that's a different story.
What's your opinion on this?
The text was updated successfully, but these errors were encountered: