Clean architecture. What are the speaker's work?

I read several articles about pure architecture and how this can be implemented in android. I saw an example application example that shows its Android implementation. Also, I watched a nice talk about clean architecture on Android

So, I understand most of the concepts, but there is some clarity that I would like to get certain things.

According to my understanding,

  • The viewing level is the external layer that is related to the user interface, and related to the career.
  • A host is a direct communicator for presentation that accepts user inputs and performs certain use cases based on this, passing it to the level of use or level of interaction.
  • Interactor fulfills the use case, returns it back to the return message sent by the host,
  • The presenter again converts this result into a presentation of an understandable data structure (ViewModel) and simply passes it back to the view.

I do not list more detailed information about the inner layers, such as the repository, since my question is related to the above steps.

Here, does the facilitator have the only job acting as an intermediary between UseCases and the UI, as a data manager?

Does only the view model use case model transformations and vice versa?

Input validation logics rely on which layer? Could it be inside the lead? For example, if we take a small example of the registration process,

As soon as the user has entered the data and pressed the registration button and the data sent to the master is like

  • The host checks the input values ​​if any error there notifies the view
  • If the values ​​are correct, convert them to a usage model and execute a specific use case, and as soon as the result is set by the interactor, convert it back to view mode, send it for viewing.

And the second question: who controls the navigation? View or Presenter or UseCase?

who decides where to go next?

For example, consider an example of using the login process, where the user enters credentials and click OK.

Upon successful login

  • If the user does not check email, go to the email check screen.
  • If the user profile is not completed, configure the profile, and then go to the main screen
  • If the user is new, display the screen for new offers, and then go to the main screen.

So, who is responsible for making these decisions on which screen to move on? Is he the moderator who decides and reviews the presentation accordingly? Or is the responsibility for using the handlers of the person responsible to inform the facilitator of what the next state is?

Sorry to ask the question too long, but I just wanted to talk about my current understandings. thanks in advance

+5
source share
1 answer

Here, does the lead have the only job as an intermediary between UseCases and the UI, as a data manager?

Yes

Input validation logics rely on which layer? Can it be inside the lead?

verification should be based on the business layer, and not on the presentation, can it be inside the lead? Of course, this is possible, but what if you have several screens with similar inputs, you need to repeat your verification logic inside each host! you can argue that you can make a basic presenter, but this is not an ideal solution, because the leader should have one goal.

And the second question: who controls the navigation? View or Presenter or UseCase?

Do you think that the navigation system is part of a domain or presentation or data level, it is probably related to the presentation level, but you can make a small component inside the presentation layer that will control the entire navigation as a whole, so you can use this component in that the moment you decide you need a different platform and drop your actions. You can find this approach in the above sample.

EDIT: 0

How do you transfer data between modules where they have different models?

you just use file cabinets, and the reason is that each module has its own models or objects, so it would be easy to test each module separately.

About the presenter and presentation, let's say you want to show an error message, the host decides why it will be shown, viewing decides how it will be shown.

I think that the problem is in understanding the level of presentation of clean code with Android, that actions and fragments are not only viewing, but also the process and life cycle in which your code will work, clean code came to a separate spaghetti for these actions and fragments.

EDIT: 1
adding to the last point, it is now clear that Google and the support team there have made great efforts to make outdoor activities and fragments of a fictitious representation as possible by introducing a large set of libraries " Architecture Components ". I urge everyone to test them, even if you use MVP, you will find great benefits.

+9
source

Source: https://habr.com/ru/post/1272256/


All Articles