The bottom line is that I read enough articles about the MVP in Habré, as well as studied StackOverFlow and, in principle, I myself understand this pattern. Understandable architecture and the need for DI, but this is what I really can't understand - by what rule / principle is it necessary to create interfaces for Model / View / Presenter? Which methods to include in the interface: the most essential, which are responsible for the main tasks or all? And similar about drawing up interfaces. Maybe I searched a little, but the articles with examples show simple examples, where the number of methods in the interface corresponds to the number of methods in the model, for example. I would very much like to understand the implementation of interfaces.

    1 answer 1

    Generally in Presenter to make the logic of working with the server and database,

    therefore, the type logic ("make a request there and return the result (asynchronously)") is made to the interface, a view only reacts with some changes in the markup, or some other logic does.

    So in the interface (for view) there will be methods of the type ("show the loder", "show an error", etc.)

    • Those. need for all presenter to build one interface? Or the number of interfaces may be different, for example, depending on the structure of different Presenter? - Serious Down
    • @Gadman From my experience, you will definitely need to follow the life cycle of an activation or a fragment or twist. So - yes, you have to make a basic interface that will contain at least methods of the life cycle, and which interfaces you will describe for different views and presenters, already to your imagination. - Eugene Suetin
    • Thank you very much. Now I figured out - Serious Down