5

Question 1: What is the correct way to build a Use Case (or more than one) with 2 ways to do the same action?

For example:

I have a 3 screens in an iOS app:
1. A map view, which can be "long pressed" and has a camera button.
2. A camera view, which is shown if the user taps the camera button in the map view.
3. A place/pin editing view, which is shown if the user "long presses" the map view, or after the user chooses a photo in the camera view. This editing view has a save button to actually create the place with a photo and the location (long press coordinate or current location in case the camera button was presses).

Title: Create Place Basic flow:
1. User “long press” on the map.
2. App drops a temporary pin and displays the place editing view.
3. User edits the place information and presses save button.
4. App creates the place and save it.

Title: Create Place Basic flow:
1. User presses plus button.
2. App displays camera view.
3. User takes a picture.
4. App creates place with current location and picture.

UPDATE based on comments exchanged with bhavik.

Question 2: (Based on bhavik's answer)
So I don't need one presenter for one interactor precisely, I can have 1 interactor and 3 presenters/views.

  1. In my case, I should have one presenter/view for the map, which is where it starts,
  2. then I should have one presenter/view for the camera, in case the user taps the camera button
  3. and one presenter/view for the editing view, in case the user "long presses" or after the user chooses the photo from the camera presenter/view and is redirected to the same editing view.

Is that correct?

Question 3: Should my boundary methods for the interactor always return void?
In bhavik's example they are returning something, but in the VIPER blog and the uncle Bob's video they always return void and the result comes in the form of another boundary method that the interactor calls on the presenter/controller.

Question 4: The VIPER way does not use a controller, only a presenter to talk to the interactor, when the uncle Bob's video uses a controller and a presenter for different interactions with the interactor. Which approach should I take?

Question 5: If my Use Case is something like "Go to other screen", should it even have an interactor? Since the current view will tell its presenter what button was pressed (what view to go to) and this current presenter will tell its wireframe "change to this other wireframe".

Rodrigo Ruiz
  • 4,248
  • 6
  • 43
  • 75

4 Answers4

12

Question 1: What is the correct way to build a Use Case (or more than one) with 2 ways to do the same action?

In VIPER design, you can create two methods in the same Interactor suitable for each primary and alternates of the use case.


Question 2: (Based on bhavik's answer) So I don't need one presenter for one interactor precisely, I can have 1 interactor and 3 presenters/views.

Based on our discussion and your updates, I think I understand it better.

  • Presenter/View should not interact with more than on Interactor.
  • Presenter/View may not interact with any Interactor at all as in case of CameraView.
  • They are intermediate views as in Wizards.
  • Multiple Presenter/View can interact with single Interactor.
  • Interactor does not bind to any Presenter.
  • Single Interactor is responsible for single use case and all of its alternate flows. 1-1 relationship.

So, you should have single EditPlacePresenter/View for EditPlaceInteractor that pass data Place data with or without Photo.


Question 3: Should my boundary methods for the interactor always return void?

In bhavik's example they are returning something, but in the VIPER blog and the uncle Bob's video they always return void and the result comes in the form of another boundary method that the interactor calls on the presenter/controller.

I think you are referring to the below Presenter method that receives results from the Interactor.

- (void)foundUpcomingItems:(NSArray*)upcomingItems

For the above to work, the Interactor will have delegate instances that will be wired/patched through by the Presenter/Controller looking for result or data. This means the Presenter/Controller is tied to Interactor or their reference or return-function-pointer is passed in each Interactor method call. Is that by design?

I think, Interactor should return data as per the use case. For example Interactor should return the EditPlaceResult with success or failure.

  • If success, it should include saved data, for example Place ID.
  • If failed, should include fail reason.

This should be part of the use case. If not then, it should not return anything. It will return void and a separate Interactor will be queried by Presenter to check if Map Place was added successfully or not.

References in the blog:

  • Presenter contains view logic for preparing content for display as received from the Interactor.
  • Its up to the Presenter to take the data returned by the Interactor and format it for presentation.
  • The Presenter receives results from an Interactor and converts the results into a form that is efficient to display in a View.

Question 4: The VIPER way does not use a controller, only a presenter to talk to the interactor, when the uncle Bob's video uses a controller and a presenter for different interactions with the interactor. Which approach should I take?

You need to define VIPER routes for following navigation:

  • Camera Button: Navigate from MapView to CameraView (Use Location)
  • Long Press: Navigate from MapView to EditPlaceView (Use Coordinate)
  • Photo taken: Navigate from CameraView to EditPlaceView
  • Save Place: Send Interactor a request to Save Place with/without Photo as the case may be and jump back to MapView if successful
  • Back Button: Back to previous View based on Navigation Stack

As per the VIPER blog, view controllers and navigation controllers are used by Presenters and Wireframes.

VIPER Wireframe handles Navigation and makes view controllers become lean, mean, view controlling machines.

Basically Wireframe abstracts away navigation controller and instead provides route definition.

Wireframe

  • Owns UINavigationController and UIViewController
  • Responsible for creating a View/ViewController and installing it in the window
  • Routing are defined in Wireframes and contains navigation logic for describing which screens are shown in which order

Presenter

  • Uses Wireframe to perform the navigation
  • To keep view controllers lean, VIPER need to give View Controllers a way to inform interested parties when a user takes certain actions - Presenters come here!
  • The view controller shouldn't be making decisions based on these actions, but it should pass these events along to something that can - Presenters should be making decisions!

Question 5: If my Use Case is something like "Go to other screen", should it even have an interactor? Since the current view will tell its presenter what button was pressed (what view to go to) and this current presenter will tell its wireframe "change to this other wireframe".

No. Navigation as part of use case may not need Interactor. It is transition only. The target Presenter may need an Interactor. For example, CameraView/Presenter does not need Interactor but EditPlaceView needs to save the place.


Overall: The idea behind architectural patterns is to divide a given software application into interconnected parts, so as to separate internal representations of information from the ways that information is presented to or accepted from the user. MVC, MVP, MVVM, VIPER all focus on isolating View, Logic and Navigation in one way or other.

Architectural patterns are limited in what they intend to decompose. We have to understand that architectural patterns do not decompose or isolate everything. Also if one architectural pattern delegates certain responsibilities to certain part, other does not do that at all probably or assign multiple responsibilities to single part.

We are allowed to extend or limit the isolation and decomposition to the extent that it justifies the cause and does not impose unnecessary separation of concerns that overrun the cost. You can choose to use navigation controllers and your presenter can take dependency on them without Wireframe routes defined. These controllers then will be responsible for the navigation between screens.

bhavik shah
  • 573
  • 5
  • 12
  • Very good answer! About question 3: maybe I didn't understand your answer here, but what I meant was, should I use the "findItems()" with "foundItems(Items)" method (so delegation), or "(Items)findItems()" or "findItems(Block(Items){})" (in case the method needs to be async). About question 4: when I say controller here I don't mean ViewController, what I meant was that uncle Bob uses a controller and a presenter to act as input and output for the interactor (respectively). So should I have a Controller and a Presenter for that or just a Presenter to be the input and output of the Interactor? – Rodrigo Ruiz Sep 26 '14 at 17:12
  • For question 3: I would use (Items)findItems(). In case, it has to be async, a way to call findItems() in async way from Presenter. The Interactor does not have know it is being used in async way. It is the Presenter who should be making such decisions. For TDD and Unit testing, you would not need async behavior. Just sequential method calls. – bhavik shah Sep 26 '14 at 17:39
  • For question 4: Presenter would alone should be the eyes and ears for the View. There is no need for a dedicated Controller in this design so far because iOS does provide Controllers out of the box as part of the SDK. They are wired into the overall UI Toolkit. So there is no getting away from it and VIPER does seem to take advantage of it under the hood. Whereas, in uncle Bob video, it is for the Web (Rails) in general and for Ruby in specific. So there will be needs for dedicated controller to handle certain View and Navigation specific behavior. – bhavik shah Sep 26 '14 at 17:39
  • Only one more question, when you say "Presenter/View should not interact with more than on Interactor.", what should I do when 2 use cases are related to the same presenter/view? For example, I have a presenter/view who has to check if user is logged in and also has to ask for user location authorization before doing anything else. – Rodrigo Ruiz Sep 27 '14 at 05:00
  • For question 3: I need some things to be async because the login, for example, is a facebook login, so I need to wait for the use to return from the facebook app. – Rodrigo Ruiz Sep 28 '14 at 04:06
  • Hey, what you think about this question? http://stackoverflow.com/questions/28892833/clean-architecture-robert-martin-how-to-connect-use-cases – Rodrigo Ruiz Mar 06 '15 at 19:12
4

Question: What to do when 2 use cases are related to the same presenter/view? For example, I have a presenter/view that

  • Checks if user is logged in and also
  • Asks for user location authorization before doing anything else.

Answer

Use Case Modelling

It seems that you are dealing with non-trivial use-case modelling scenarios.

"Check user-login" does not need use case. Similarly, if location authorization is not being updated as part of configuration settings, then it is also not a use-case. They are not good candidates for use-case modelling but rather preconditions or "steps" in other complex use cases. I think they are more like preconditions then "steps" and certainly not individual "use-cases" themselves.

Preconditions should be accompanied by use-case exceptions and non-trivial "steps" hints use-case-reuse via include-dependencies. If preconditions fails, you can provide appropriate messages and options to fulfil those conditions. For complex steps, one use case redirect to other use-case.

The idea is to either opt for exceptions that will terminate the use case with valid message on failed preconditions OR include other use-cases that will ask user to log-in first and resume current use case.

The goal is to break down complex requirements and re-use them. Quoting from Use Case Reuse - Include Dependency. "You use include dependencies whenever one use case needs the behavior of another. Introducing a new use case that encapsulates similar logic that occurs in several use cases is quite common."

In VIPER Way

  • Interactors should know about other Interactors if required.
  • Rules and preconditions should validated in Interactors or in Entities as required.
  • Interactors should return appropriate data for Presenters.
  • Presenters should NOT know about other Presenters that are part of other use cases.
  • Presenters should send requests to Wireframe.
  • Wireframe should take care of appropriate navigation to different Views.

Thus,

  • CreatePlaceInteractor should take dependency on UserLogInInteractor and LocationAuthorizationInteractor and call them when necessary.
  • Or CreatePlaceInteractor should send back data that Presenter can interpret and ask Wireframe to launch UserLoginPresenter and/or LocationAuthorizationPresenter.

This will involve carefully designed interactions and navigation for control flow and data flow using Interactors, Presenters and Wireframes. In the process, you will be challenging lot of core assumptions and hidden unhandled system behaviour.

Since other use cases may also include user-login or authorization-access to finish their task, these use cases should be included but not necessarily executed all the time - conditional function call to UserLogInInteractor and LocationAuthorizationInteractor. If user is logged in and authorization access is already allowed, they will be skipped. When user chooses CameraView, check for user-login and location access. When user chooses EditView directly from MapView, check for for user-login only.

I think you should implement precondition logic into your Interactors and Presenter can use it to make Presentations and Navigations related decisions.

Considering following list of Use Cases:

  • "UC001: User Log In".
  • "UC002: Get Location Access Authorization".
  • "UC003: Show Map".
  • "UC004: Create Place on Map".

UC004: Create Place on Map (With Preconditions)

Preconditions:

  1. User is logged in.
  2. Location Access has been authorization.

Steps:

  1. If preconditions are NOT met, run appropriate exceptions.
  2. Other steps for "Create Map Place"

UC004-E1: User is NOT logged-in or session expired

Steps:

  1. Show appropriate message to the user for log-in or session expired and provide log-in option (button).
  2. terminate use case. [user can choose to go back to map view or go to log-in screen]

UC004-E2: Location Access has NOT been authorized.

Steps:

  1. Show appropriate message to the user for setting location access and provide setting options (button) in the configuration.
  2. terminate use case. [user can choose to go back to map view or go to settings options]

UC004: Create Place on Map (Without Preconditions)

Steps:

  1. Check user is logged in and user session is active. If not, run UC001.
  2. Check if user has previously authorized Location Access. If not, show appropriate message and run UC002.
  3. Other steps for "Create Map Place"

UC004 > UC001: User is NOT logged-in or session expired

Steps:

  1. Show appropriate message to the user for log-in or session expired and run UC001
  2. User logs-in successfully, continue UC004 Step#2
  3. User is not logged in successfully, terminate the use case.

UC004 > UC002: Location Access has NOT been authorized

Steps:

  1. Show appropriate message to the user for location authorization and run UC002
  2. User authorized location success, continue UC004 Step#3
  3. User did not authorized location access, terminate the use case.
Community
  • 1
  • 1
bhavik shah
  • 573
  • 5
  • 12
  • I got it when you said that an interactor can call on other interactos, makes sense. But about the login/location, it was just one example, what about something like Create, Edit and View actions? Those are on the same presenter/view, the PlaceDetailViewController/View, the edit happens when you press a button and the fields become editable (but on the same view), the View action is before you press the edit button and the create action is like I said before, when you are creating a new place. But all those 3 actions end in the same ViewController. – Rodrigo Ruiz Sep 28 '14 at 04:01
  • Should I create only one use case (interactor) for view, edit and create? – Rodrigo Ruiz Sep 28 '14 at 04:04
  • bhavik, could you help me with that last question? Just to be more clear, another example is: my MapViewController has a button that when you tap, it tracks the user's location and the MapViewController also displays pins for places retrieved from server. In this case I thought of 2 interactors, PlacesInteractor and CurrentLocationInteractor. The PlacesInteractor retrieves the places and the CurrentLocationInteractor is responsible for requesting user's location authorization and getting the most updated coordinates. So what should I do to have at most one interactor for each presenter/view? – Rodrigo Ruiz Oct 20 '14 at 04:41
  • Hello Rodrigo, apologies for not replying sooner. However, during the time I have been myself confronted some design problems and I came up with the idea of dividing various different parts of the application between Front-End-Participants and Back-End-Participants. It encourages me to think clearly. Just thought of sharing with you - while I am still trying to exploit this idea further where it makes sense. See my reply to your questions below. – bhavik shah Oct 23 '14 at 14:00
2

Use Case Modeling and VIPER Design considerations for - Create, Edit and View "A Place on Map" for a iOS based mobile application

Your questions

  1. What to do if - Create, Edit and View actions end-up in the same ViewController?

  2. Is it a good idea if MapViewController uses PlacesInteractor to retrieve the places and the CurrentLocationInteractor to request user's location authorization and getting the most updated coordinates?

It is not a problem to combine related logic into single Interactor. But it will not longer be an "Interactor". It will become a "service" or "manager" as in MapPlaceManager/MapPlaceService which will have methods such as:

canCreateMapPlace
createMapPlace(Details)

getMapPlaceCount
getMapPlaceIDs
getMapPlaceDetails(ID)

canUpdateMapPlace
updateMapPlace(ID, NewDetails)

I think the idea was to expose only the intended APIs per use case and hence Interactor - which can clearly state what the user of that Interactor is going to do with it. If it has multiple APIs that can do different things like create/edit/delete map places, then we have to check the method calls in the caller to know what the caller is going to do. Interactors in this sense to me are very high level - business/requirements level interfaces. You can hide your back-end services and managers inside these individual Interactors.

You can take this notion to as far as possible and/or feasible - Feasible rather possible. There will be an extreme where we draw the line, instead of following it too religiously. Business systems tend to be more formal and methodical to give you an example.

In your case, when a button is pressed on your main view that changes your MapPlaceView into MapPlaceEditView, you are changing the use case that the new view is going to satisfy. Such in-place view changes are appropriate view design considerations for mobile and also it is use friendly. However, often it encourages complex GUI and messy presenter logic. If it is manageable, cleaner and easier for your ViewController/Presenter to switch "modes" between "Create, View, Edit" - you are good to go. It is not perfect, but it is not wrong. They are Front-End-Participants and have the highest level of freedom and frequency of changes anyway.

An alternate good UI design I have found useful instead of in-place fields editing, is "flipping" the views or any such view transition effect. You can have a MainMapPlacePresenter/ViewController and it has 3 sub views - for Create, Edit and View. This main view is then responsible for switching between these three views. It enables cleaner navigation, cleaner use case implementations and neat design.

Similarly for CurrentLocationInteractor, it does two things - 1. request permission to use "device location service" and 2. use "device location service". Now, it seems it is not an Interactor at all. It is Front-End functionality. But you can use SaveAuthorizationInteractor to save user's choice. But that is different thing. The more I think, Interactors are responsible for things that deal with your system and not with your user.

Presenter does all the "user-talking" and "decision-making" work - they may use device APIs if they need e.g. Location Service. You can create abstract interface ILocationService and wrapper implementation called LocationService that will absorb user's device location service - low level implementation and platform-specific detail.

In implementation terms: You can have:

MainPresenter/MainViewController
On Load - Show MapView along with Buttons for Edit and Create Map Place

MapPresenter/MapViewController
On Load - Show Map
    Navigations - login, authorization, create, edit
    Interactions - none

MapPlaceCreatePresenter/MapPlaceCreateViewController
    On Load - call MapPlaceCreateInteractor.canCreateMapPlace - Response = {AllGood, UserNotLoggedIn, LocationIsNotAuthorized}
    Interaction - MapPlaceCreateInteractor.createMapPlace - Responses = {PlaceCreatedSuccessfully}
    Navigations - Login, Location Authorization, Back to Main View (With Response - UserLoginNeeded, UserAuthorizationForLocationAccessNeeded)

MapPlaceUpdatePresenter/MapPlaceUpdateViewController
    On Load - call MapPlaceUpdateInteractor.canUpdateMapPlace
    Interaction - MapPlaceUpdateInteractor.updateMapPlace(ExistingMapPlaceID, NewDetails) - Responses = {PlaceUpdatedSuccessfully}
    Navigations - Login, Location Authorization, Back to Main View (With Response - UserLoginNeeded, UserAuthorizationForLocationAccessNeeded)
bhavik shah
  • 573
  • 5
  • 12
  • About question (1), maybe my example wasn't a good one =), I don't actually have view, edit and create on the same view controller, I have other stuff, like view (displaying the places) and category filter (buttons that filter which places are shown by category), and those 2 seem that they should be on different interactors, thats the case I don't know if I have 1 interactor for both or 2 interactors for the same presenter. As for question (2), I think I get it, my only concern is that won't I be creating tons of classes with only 2 methods? – Rodrigo Ruiz Oct 27 '14 at 14:04
  • And as for the location service, you think it is ok for the presenter to have a CLLocationManager then? – Rodrigo Ruiz Oct 27 '14 at 14:04
  • I think presenter should use CLLocationManager. It is provided by the iOS platform and it is not directly encapsulated by your application. However, as I mentioned before, you can wrap it through a location manager interface if you want to isolate your presenter from implementation dependency on CLLocationManager - which is a good idea by the way. – bhavik shah Oct 27 '14 at 14:10
  • In my opinion, a well designed software does tend to be more and more granular and lean. It means very small classes with few fields and methods. If done right you will have tons of classes, yes! I have lots of classes in my projects. Even filters are classes for example with LocationFilterCritera field (can be enum) and so on. In my projects, I use such filter objects. You can add more criteria to your filter object or create new filter classes - there by not changing the old code. As for Interactors with just couple of methods - well, if it makes absolutely clear design - it is worth it! – bhavik shah Oct 27 '14 at 14:17
  • Places with Filter Criteria should be part of one view. Its presenter will have an Interactor that retrieves filtered places based on criteria provided to the Interactor. ------- By the way, I am not saying it is mandatory to create per use case interactors - you have to find a balance between verbosity, granularity, redundancy and amount of work with respect to the gain should you choose very lean Interactors. I have seen frameworks and architectures that favors such ideas and they provide great flexibility when you use such frameworks due to their focused classes. What do you think? – bhavik shah Oct 27 '14 at 14:24
  • I think it is worth the try, since I've written this project in Objective-C and its classes were getting too big and too complicated to maintain, thats why I decided to rewrite it (and also to try learning swift). About the Filter Criteria, should I create one presenter just for this FilterView (UIView) ? It is a view that is displayed at the top of my MainViewController's view. Also if I do, it is ok that this presenter does not "present" anything right? I mean, it will just receive information from that UIView (also won't have a UIViewController in the middle). – Rodrigo Ruiz Oct 28 '14 at 04:25
  • Filter Criteria are associated with your Places being displayed. So they are not detached and separate. Hence no need for separate Presenter, UIView or Controller. If it is possible, the filters GUI should be in the same view that displays and filters Places. Separate UIView+Presenter makes it inter-presenter communication scenarios. – bhavik shah Oct 28 '14 at 06:00
  • Thank you a lot for all your answers bhavik, you've helped me a lot and for so long. – Rodrigo Ruiz Oct 28 '14 at 14:46
  • Should I use a different interactor instance for each presenter that uses it or should I use the same instance for every presenter? – Rodrigo Ruiz Oct 30 '14 at 15:10
  • I am afraid that question is outside the scope of our discussion since it deals with the application run time behavior such object life cycle requirements, thread-safety and re-entrant code. If your Interactor or for that matter any service-provider object is thread-safe, you can share instance among presenters or its clients. Check [here](http://stackoverflow.com/questions/261683/what-is-meant-by-thread-safe-code) and [here](http://stackoverflow.com/questions/2274254/what-kind-of-code-can-be-called-re-entrant) – bhavik shah Oct 31 '14 at 08:26
  • Should I have 2 Interactors for the cases "list places in map" and "view place details" (in a separate view)? I'm asking this because those 2 interactors would look very similar in terms of code, both would retrieve place information, the difference is that "list places in map" would return a list and fewer details of the place, while "view place details" would return all information about the place and only for one place, so should I try to avoid code repetition or just create the 2 interactors? – Rodrigo Ruiz Nov 03 '14 at 14:37
  • From use case modelling perspective and interactor design goals, Related methods may go in single Interactor. [Check this out](http://stackoverflow.com/questions/15200362/when-to-use-single-method-interfaces-in-java/15208673#15208673), also [Functional Interfaces](http://blog.sanaulla.info/2013/03/21/introduction-to-functional-interfaces-a-concept-recreated-in-java-8/) – bhavik shah Nov 05 '14 at 10:09
  • Their code is related (almost the same in some parts), but their use aren't related. – Rodrigo Ruiz Nov 05 '14 at 15:29
1

It appears that the two use cases seem to have identical end results that is "Create a Place with / without picture" with two ways - "With Camera and Location Service" vs "Manual Data Entry".

The "With Camera and Location Service" use case adds photo as well.

However, I am wondering if two ways of achieving the same result or identical result is considered single use case.

I would design the two as separate use cases if I can, otherwise I would make one as primary or default use case and other approach as an alternative to achieve the same / identical end result.

Use Case: Create Place

Basic flow: Use Camera and Location Service

  1. User presses plus button.

  2. App displays camera view.

  3. User takes a picture.

  4. App creates place with current location "and picture".

Alternate flow A: Use manual data entry

A.1. User “long press” on the map.

A.2. App drops a temporary pin and displays the place editing view.

A.3. User edits the place information and presses save button.

A. 4. App creates the place "without picture" and save it.

Does this make sense?

Updates with specific details

The View Controller responsible to deal with View in iOS, is in fact treated as View in VIPER. See the "View" paragraph. A UIViewController, or one of its subclasses, will implement the View protocol. Hence this controller is your View.

The idea is you need to isolate your Presenter from the knowledge of iOS View or iOS controller. It should deal with iOS specific view and controller via plain data structures like ViewModels. If you can do that, you have successfully isolated Presenter from iOS SDK specific dependencies and you can write and run TDD or Unit tests directly on your Presenters if you want.

However, more interestingly once you succeed in isolating Presenter from View and ViewController, you can isolate Interactor from Presenter easily. Presenter will have to pass data in the form that is acceptable to the Interactor. So Interactor does know nothing about Presenter. It's independent and you can this Interactor (Use case) in command-line, web or desktop-GUI app as easily.

I think there should be one Interactor per use case. If there are alternative flows to the use case, the interactor will have methods with those alternative data structures.

In your case the CreatePlaceInteractor will have two methods:

CreatePlaceWithManualDataEntryResult createPlaceWithManualDataEntry(CreatePlaceWithManualDataEntryRequest)

CreatePlaceWithCameraAndLocationServiceResult createPlaceWithCameraAndLocationService(CreatePlaceWithCameraAndLocationServiceRequest)

There will be three View/Presenters:

  1. CreatePlaceChoicePresenter/View will capture user choice and send the request to the NavigationController or Wireframe as appropriate which will return new Presenter/View according to the user choice.

  2. CreatePlaceWithManualDataEntryPresenter/View will create and convert CreatePlaceWithManualDataEntry ViewModel into CreatePlaceWithManualDataEntry Request and will receive CreatePlaceWithManualDataEntry Result and process accordingly to display the use case result on the view.

  3. CreatePlaceWithCameraAndLocationServicePresenter/View will create and convert CreatePlaceWithCameraAndLocationService ViewModel into CreatePlaceWithCameraAndLocationService Request and will receive createPlaceWithCameraAndLocationService Result and process accordingly to display the use case result on the view.

Apologies for being verbose on request, resonse, viewmodels and method names.

bhavik shah
  • 573
  • 5
  • 12
  • It does. I'm actually trying to write use cases to follow this pattern: https://www.youtube.com/watch?v=WpkDN78P884, but with iOS. So having 2 use cases means having 2 Interactor classes. Is that what you think I should do? Thanks btw. – Rodrigo Ruiz Sep 24 '14 at 16:20
  • If "Interactor" is part of your VIPER design as described in [VIPER Introduction](http://mutualmobile.github.io/blog/2013/12/04/viper-introduction/), you probably should go with two Interactors. The reason being single Interactor deals with single Presenter and View, and in your case, you will have two different presenter/view for two different flows. – bhavik shah Sep 24 '14 at 17:18
  • I will actually have more than one presenter/view for each Use Case, similar to a multi-step form on the web (in my case, the map view, the camera view and the edit view). Should I use 1 interactor with 2 presenters for each Use Case? – Rodrigo Ruiz Sep 24 '14 at 19:38
  • Also, that VIPER link, it shows only a Presenter, shouldn't I also have a Controller? The Controller being responsible for receiving input from the view and the Presenter responsible for presenting the view? – Rodrigo Ruiz Sep 24 '14 at 20:24
  • I did watch the video last night. Very good video and thank you for sharing. See my updated answer above. – bhavik shah Sep 25 '14 at 09:53
  • I think I got it. So I don't need one presenter for one interactor precisely, I can have 1 interactor and 3 presenters/views. In my case, I should have one presenter/view for the map, which is where it starts, then I should have one presenter/view for the camera, in case the user taps the camera button and one presenter/view for the editing view, in case the user "long presses" or after the user chooses the photo from the camera presenter/view and is redirected to the same editing view. Is that correct? – Rodrigo Ruiz Sep 25 '14 at 21:11
  • Another question that I have is, should my boundary methods for the interactor always return void? In your example they are returning something, but in the VIPER blog and the uncle Bob video they always return void and the result comes in the form of another boundary method calling from to interactor to the presenter/controller. Also, the VIPER way does not use a controller, only a presenter to talk to the interactor, when the uncle Bob video uses a controller and a presenter for different interactions with the interactor. Which approach should I take? – Rodrigo Ruiz Sep 25 '14 at 21:14