-
Notifications
You must be signed in to change notification settings - Fork 165
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
using API specifications (url , ...) in data layer violates Dependency Rule?! #11
Comments
Hi @orca741
This is actually a good ideia, I'll try to do that as soon I manage to find some time. But one approach would involve adapting the existing
This way, the domain layer remains agnostic to storage concerns, with all database-related operations encapsulated within the
Actually, this is debatable! 😄 In simple terms, the rule suggests that "inner layers shouldn't depend on outer layers." Despite the URL being hardcoded, it's exclusively utilized by that class and doesn't directly influence other parts of the app. However, it might complicate testing efforts. To address this, we could inject it through the constructor along with Dio. This adjustment would be a good improvement to this project. |
Great. Sufficient and clear explanations. 👍
What do you think about this schematic: This is my understanding from Reso coders tutorial, your explanation and of course Uncle Bob's article. As Uncle Bob said:
now we can replace fourth layer with any other framework without any customization in 3 inner layer. This is nothing new at all, but I want to know your opinion about my vision of Clean Architecture and any suggestion or correction. |
Hi @orca741, great schematic! Here are some thoughts Domain:
Data: I'm a bit uncertain about including Riverpod in this layer. I understand your point - Riverpod (and other state management libraries) can be utilized independently of Flutter. For instance, we have both In my projects, I typically delegate dependency injection to a dedicated package like Side note:
This is purely a personal opinion based on no evidence, but it seems to me that most projects gets to a point where it's good do not apply rules 100% in order to simplify maintenance. When Uncle Bob made the above statement, technologies like ORMs were new and likely subject to frequent changes. Today, in the Flutter ecosystem, we encounter a similar situation. While you might find yourself testing and replacing various state management libraries, but it's rare to replace foundational components like the library used for accessing shared_preferences, an ORM, or making network calls. Therefore, it's wise to make the project flexible where flexibility is likely needed - and to avoid over-engineering :) |
Hi @guilherme-v .
the
I accept that. In this repo's I thought that the purpose of what these libraries do, is to provide data. On the other hand, in Uncle Bob's documentation, this layer is named as
This is my biggest bug, over thinking and excessive adherence to rules.😑I agree that with real ORM, there is no need for boilerplate codes in 4th layer for DB data exchanges and It should be All in all, I found the answers and thank you for being so responsive. I hope to be able to use your knowledge again in the future. |
Hi.
Thanks for your work I learned a lot from that.
I wonder if we use this 3 layer architecture (Domain-Data-Presentation) as you did, using details from external data sources (such as API Urls, DB table names, DB syntax and etc.) in data layer, doesn't violates Clean Architecture Dependency rule? from Uncle Bob's manifest the last layer contains DB and if we consider that as raw DB and bring DBManager(ORM,...) to inner layer(adapters),It should know about outer details. Should we use Dependency Inversion again?
In your code, API's Url is hard coded in
api.dart
in data layer and if we consider API as an outer circle component,I think It violates Dependency Rule.If you want to add DB as a source to this project, How you do that?
Thanks.
The text was updated successfully, but these errors were encountered: