-
Notifications
You must be signed in to change notification settings - Fork 188
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
[Question] Non-trivial module to module communication #8
Comments
I talked about some people about this and at some point you need to have a connection between the layers. Either by soft reference (ID of the object to be edited) or a dedicated "transition" class between two modules that receives/transforms an object. Either way this architecture requires an interactor to pass enough data so that a unique object can be retrieved later on or the interactor passes a plain object that is a 1:1 copy of the database entity so that you can reuse it for the other module. In my example app, I am just copying the database entity basically and the only transformation happens in the presenter from Model to View model. The presenter could save a map (i.e. Dictionary) that maps the model with the view model. Now you can do the following: ViewController says to the Presenter: "This ViewModel was selected, please do something". Presenter gets the corresponding "real" model and passes it on to the wireframe and so on. Anyway, interesting topic and I don't think there is one bullet-proof solution for this problem. Hope that helps! P.S. I'm really glad about this architecture design but it's a shame that there is no response from the authors in such a long time. :( |
Thanks @sebastianwr.
I like the idea of a dedicated transition object (or Data Transfer Objects - DTOs as we tend to call them in C#) by reference. I agree there isn't a prefect solution; I guess that is why there are so many implementations of the MV* pattern.
Yes, this is by far the best architecture design I have found. The lack of discussion about this reflects my experience of iOS development - the majority of iOS devs don't use patterns, just monumental ViewControllers and singletons. Urgh. |
I think what we will use in our next private project is a mixture of a massive view controller and the VIPER architecture. The VC will not be doing too much work but gets data passed or asks other classes for what to do next. Decoupling of classes and having a single responsibility (i.e. "control your own view") is the main goal. So I'd say whatever you do to achieve decoupling will help the overall software design. |
how about viper nesting? sorry for my poor english~ |
So I came smack dab into this issue myself on a project. I am coming to the conclusion that the wireframe needs to know a lot more about the interactor layers. I also believe the instantiation of the entire module should happen in the wireframe. In essense the wireframe is the transition object you talk about. It should know how to pull data and dependencies from one module to insert into another at the interactor level up. This doesn't seem to be super "clean" but neither does passing massive amounts of data through presenters and wireframes on each side. What do you guys think? |
Even though this project seems to be abandonware, there aren't any better forums for discussing VIPER, so I hope there's someone actually implementing it IRL. (i'm gonna ask on StackOverflow as well).
Every example of VIPER I have found only provides a contrived example of communicating from module to module. The TODO app opens a blank Add screen. No information is needed from the previous (list) screen. That's the most simple (and contrived) example possible. But in reality there are lots of situations where you need to pass info from screen to screen.
For example, lets say we wanted to extend the TODO app to allow editing of todo items. In order to edit, you need to pass some info to the edit screen (module). Because communication happens between modules via wireframes, would I modify the
VTDListWireframe
so that theVTDListPresenter
can call something like this:Notice how my wireframe is now taking todo string. Is this in keeping with the VIPER pattern, or am I violating the boundaries between presenter and wireframe? Is there another way I should be communicating this to the next wireframe?
The text was updated successfully, but these errors were encountered: