mvp

Improving MVP in Scala

为君一笑 提交于 2019-12-04 10:01:54
The classical strongly typed MVP pattern looks like this in Scala: trait IView { } trait Presenter[View <: IView] { // or have it as an abstract type member val view : View } case class View1(...) extends IView { ... } case object Presenter1 extends Presenter[View1] { val view = View1(...) } Now, I wonder if there is any nice way to improve on it which I am missing... Nice thing about MVP pattern is that it makes your UI code unit testable. I'd suggest you to avoid instantiating view in presenter and pass it to constructor. That will allow you to just mock out the View and unit test the

Refactoring Form.ShowDialog() code to MVP

萝らか妹 提交于 2019-12-04 08:42:12
问题 I have a WinForm and few properties that are set on it. for example : Name,Address are accepted on the Form. (many more properties in actual example) The current implementation is somewhat similar to frmName frmView = new frmName (); //frmName is WINFORM frmView.Name= "ABC"; //any valid string or read this from file frmView.Address="SomeAddress"; //any valid address or read this from file if (frmView.ShowDialog() == DialogResult.OK) { //OK CLICK PROCESS and // get new values edited by user

MVP for Activity with multiple Fragments

北慕城南 提交于 2019-12-04 07:49:15
问题 I have an Activity with two Fragments in it. The activity ( MainActivity ) retrieves data from an open weather api. I have implemented MVP for this in which: Model contains all the response objects from the API View is the Activity Presenter contains MainPresenter , MainPresenterImpl , MainView , GetDataInteractor and GetDataInteractorImpl . So, the activity gets the data from the web service. Both fragments will display data from the data retrieved in the activity. What is the best practice

Is ASP.net Model View Presenter worth the time?

本秂侑毒 提交于 2019-12-04 07:48:45
问题 I'm reading about ASP.net MVP pattern over this weekend and it seem like even the most simple task take too much effort if do it in MVP pattern the pay off seem to be at larger project but i think to myself if i'm going to follow MVP. Why not just do the project in ASP.net MVC? The reason that I'm looking at MVP pattern is because I've noticed in all my ASP.net Webform projects there are a lot of code in the code behind just for event handling along if i have a lot of server control on the

Pass bundle intent in android using MVP

坚强是说给别人听的谎言 提交于 2019-12-04 07:24:37
I want to pass the Model data into another activity using Parceler through Bundle intent. My problem is how could I pass the data from Presenter into the View layer to display in another activity using MVP architecture in android? This is certainly possible. Presuming that your Activity implements your View interface you'd have a method in the interface like: void startNextActivity(MyData data); Then in the Activity: @Override void startNextActivity(MyData data) { // create bundle // send intent } And in Presenter: view().startNextActivity(myData); However I don't recommend that you do this I

How to apply composition in android MVP?

荒凉一梦 提交于 2019-12-04 03:04:58
Recently I took over an android project which is built on top of MVP. While simple screens are quite straight forward and easy to read and maintain, the more complex parts of the app are not. Multiple inheritance levels have caused me days of switching between classes, trying to find out how the information flow is actually working. Here one example of the more problematic hierarchies: Since we use MVP, naturally there is another presenter class and another view class for each of the classes in the diagram. So I did some research and found this article: Composition vs Inheritance in MVP and it

communicate between presenters in MVP android application

淺唱寂寞╮ 提交于 2019-12-04 02:53:34
I am using MVP pattern to build a small test android app. I have two fragments Fragment B (I am using for sliding drawer) and Fragment A (main fragment). Both fragments have their own presenters. when I click on sliding draw it should send message or invoke a method in Fragment A to update view. I want to ask , how both fragments presenter can talk under MVP. I know other solutions but I want to do it through MVP pattern. Please suggest some options that MVP pattern follows to deal such scenarios. First of all, in MVP approaches, presenter and view have 1 to 1 relation to each other. If you

How to control ListView with MVP Pattern for Android

会有一股神秘感。 提交于 2019-12-03 22:54:14
I'm currently developing an android app using MVP Pattern. When I try to develop an Activity, I should use a ListView. So I'm using Adapter for ListView. But I heard Adapter is similar to Presenter on MVP Pattern. I think if Apdater is smiliar to Presenter, then I should make Presenter for updating ListView instead of Adapter. When this situation, how to develop ListView? Just use Adapter and keep using MVP Pattern? Thanks for your reading. Yes, the Adapter should be the P component in an MVP pattern. In fact ListViews are pretty much written as MVP- the getView() function needs to set all the

How do I start a service from my Interactor using the MVP pattern in android?

≡放荡痞女 提交于 2019-12-03 17:02:59
问题 I'm following the Model View Presenter (MVP) pattern similar to Antonio Leiva's example found here: antoniolg/github. I've been playing around with it quite a bit and I was wondering how I would start a service from the interactor layer. Normally I've been putting my retrofit calls inside the interactor but I was wondering if there is a way to start a service from the interactor so I could run my retrofit calls in the service instead. Problem here is that I don't have the activity context to

What is the advantage of the MVP pattern (GWT)

我是研究僧i 提交于 2019-12-03 17:01:28
I just read this article and it did confuse me a lot. Secondly, this model allows us to minimize our use of GWTTestCase, which relies on the presence of a browser, and, for the bulk of our code, write lightweight (and fast) JRE tests (which don't require a browser). [1] Is this the whole benefit, I have from following this design pattern? It seems to make the code more complex... Do you use this pattern? topchef I have to disagree, MVP makes code way less complex, especially in case of GWT. If you plan on medium to large size GWT project then MVP architecture is your primary option. I suggest