Proposal Discussion
CodingAleCR opened this issue · 4 comments
Hey! I stumbled upon your channel by accident, glad I did! Nice stuff!! I do, however have a couple of questions.
-
Usually when you go to Clean you end up placing your Business Logic inside your domain so you can eventually reuse it, this (for me) meant that your BLoCs should be a part of that domain layer, however you place them within the Presentation Layer, what is your main reason? My guess is that since it is updating the UI like a ViewModel would do then you are placing it with the screen/view that it is working with.
-
The way you set up your folder structure also can take a toll whenever developing bigger projects, for example, you have setup domain in each feature but if you need another feature to use the same entities that another feature has, then you would be breaking your own folder proposal. To be honest, that's something I've struggled working with in Flutter. I believe a solution could be to have the presentation layer to be feature grouped and have a more general domain + data layer outside. Going with your app it would look something like:
- lib:
- data:
- datasources
- repositories (concrete)
- domain:
- repositories (edge)
- entities
- usecases
- presentation:
- feature:
- logic holder
- screen/ui/page (or whatever you'd like to call it)
- feature:
- data:
- lib:
Hello! I'm glad you find the content valuable.
As for the questions:
-
Yes, Blocs act very much like ViewModels. All of the actual logic goes into the Use Cases.
-
You make a good point in that reusing the domain and data layers is problematic when you put them inside the individual features. You propose to put domain & data "outside" of features for reusability. I'd put such reusable parts into the core folder and still have the non-reusable ones fall under specific features if that makes sense. At the end of the day, always use the structure which fits your needs.
That suggestion might be the best idea I've heard so far. It would help out with the overall code reusability.
Hi @ResoDev,
What if some of the screens need to use multiple features? For example, my app has a screen called statistics which needs to use some of the other features information to show to the users. Which folder should I put this view on? Thanks!
As per the suggestion my guess is that it would be on core
since it is a reusable feature.