Hi,
i am trying to adopt ideas from clean architecture to my app and have following question:
In my view i have to show a summary of data calculated from different entities. I dont know where to do the calculation stuff.
Is there other options, is there a best practice for such a usecase?
Thanks for any advice.
Hi @misrakli ,
Please answer following questions ?
Domain/Use case layerData layerPresentation layerI hope you will get my idea, if you have more questions please feel free to ask.
hi @CROSP
thanks for your input.
The main feature of the app is not the calculation itself. The summary (calculation) is only a "view" to the current status of some data processing like a statistics. Imagine a list of tasks with subtasks, each task/subtask can have its own status where different status are supported, the summary is giving the user the current state of the task processing. The presentation layer can decide how to work with this summary like you mentioned, for example show different statistics.
I didn't unterstand what you mean in 2) with "only retrieving data". And how should get the presentation layer in this case the calculated data from data layer, what is the role of the domain layer in this case, as i understood the presentation layer should go to the data layer only with a usecase from the domain layer.
I am going the way, that my data layer gives the required entities for the calculation to the domain layer, the domain layer calculates the summary and provides it to the presentation layer, the presentation layer itself can decide how to deal with those information.
@misrakli In my second option, I mean that if calculations are required for example for setting some arguments for query (amount of data to get from db, some calculations related to db) or http arguments (get params), so everything that is only required to retrieve data.
In your case it makes sense to put calculation logic into Domain layer because this is core of your app ( the main idea of your app).
To sum up
God objects like Activity ,because of Context, but I still try to get rid of any logic inside UI. This is how I understand Clean Architecture approach, maybe I am also wrong, so I would be grateful for any other responses.
@CROSP
the way you described is already the way i am going.
For the most use cases i have a clear idea of how to solve it with clean architecture
but it is not always easy to find the appropriate layer for the given functionality, i think it also depends on the requirements (functional and non functional). But thanks to the community one can find different views to the problem :-)
@misrakli You are absolutely right. It can be hard to find proper layer to put logic in. I have been struggling with the same problem. In some cases new layers can be introduce, but do not create new layer every time you are not sure where to put some logic.
And again these three layers described by author @android10 is just an example of commonly required layers. You can have app without Data layer at all or any other as well.
The main idea is decoupling and separating of concerns.