Skip to content
This repository has been archived by the owner on Jan 9, 2020. It is now read-only.

Add a new interface extending from RosiePresenter.View #3

Closed
Serchinastico opened this issue Nov 20, 2015 · 10 comments
Closed

Add a new interface extending from RosiePresenter.View #3

Serchinastico opened this issue Nov 20, 2015 · 10 comments

Comments

@Serchinastico
Copy link
Contributor

Some of the views we have to implement have a loading state. We are going to create a RosiePresenter.ViewWithLoading interface with two methods: showLoading and hideLoading to avoid code duplicity in all the library client code related to this classes.

@pedrovgs
Copy link
Contributor

pedrovgs commented Jan 5, 2016

We should do the same with the empty case and the error case view.

@pedrovgs pedrovgs added this to the 2.0.0 milestone Jan 5, 2016
@luis-ibanez
Copy link
Contributor

luis-ibanez commented Jun 1, 2016

I am looking at this because I faced a similar problem in another project and would be good to help and at the same time to find a standard solution.

The first proposal of this issue was to add the LoadingPresenter with the ViewWithLoading interface, to implement the show/hide loading, given that is used in a lot of views. But then appear another situations that are also widely used like the ones that @pedrovgs suggest.

I think there are 3 solutions to this:

1.- Create a lot small Views with a lot Presenters implementing each:

  • RosiePresenterWithLoading
  • RosiePresenterWithEmptyCase
  • RosiePresenterWithError
  • RosiePresenterWithNoConnectionWarning
    etc...

The problem with this one is that we couldn't extend our presenter from more than once, we could implement more than one view on the view of our presenter, but then having the RosiePresenters won't have any utility.

So I think we can easily discard this one.

2.- Create a RosiePresenterWithSteroids
We put all the methods that we can think (show/hide loading, showError, showEmptyCase... ) in this PresenterWithSteroids, and its view.

The problem is to implement this class without wanting to use all its functionality, we may end with a lot of empty implementations in the View. We could solve this with default methods form Java 8 or a NullObjectPattern.

3.- We remove this extended classes, expand the sample with more BasePresenters to help the users to get code from there, and reduce the library classes.

What do you think?

@pedrovgs
Copy link
Contributor

pedrovgs commented Jun 2, 2016

I think the option number 3 is going to be the best one or at least the most flexible one. Thoughts @flipper83 @Serchinastico ?

@Serchinastico
Copy link
Contributor Author

Yup, I'd say option 3 is the way to go until we get mixins with Java 8.

@flipper83
Copy link
Member

option 3 is the good one for me too, because two is impossible for now. and we can use any kind of composition. I have an idea, that it's have small getViews interfaces and can do something similar to.

getView(LoadingView.class).hideLoading(); or have a map for enums. and if your view have this interface implemented it, invoke it. Have this sense?

@pedrovgs
Copy link
Contributor

pedrovgs commented Jun 4, 2016

I prefer simple solutions for this case. Add the method to the View interface just if need it. IMHO documentation here is more interesting than code.

@flipper83
Copy link
Member

I was talking with @pedrovgs about have a module with addons, and add here some kind of interfaces with method that you can add to your view interfaces. Do you like the idea?

@luis-ibanez
Copy link
Contributor

luis-ibanez commented Jun 20, 2016

I think that if you look for examples, the sample is self-explanatory enough. With the module of add-ons, which solution would you implement? The PresenterWithSteroids? or just three or four cases? Is it not better just to add a couple of examples on the sample?

@JorgeCastilloPrz
Copy link

JorgeCastilloPrz commented Jul 30, 2016

Isn't this already done ? I was checking this RosiePresenterWithLoading class.

I think adding more custom view contracts like the one defined in RosiePresenterWithLoading to the sample code should be enough. It is a good way to teach users about how to define their own view behaviors IMO. You are doing more than enough providing them with all the lifecycle linking / null view objects for this layer

@pedrovgs
Copy link
Contributor

pedrovgs commented Aug 1, 2016

Yeap @JorgeCastilloPrz you are right. I'm closing this issue.

@pedrovgs pedrovgs closed this as completed Aug 1, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants