3

Considering Uncle Bob's Clean Architecture (or Onion Architecture)

Let's say that as a signed in User in my app, I receive a deep link url "myapp://events/[event_id]" (via sms, for example).

I want to join that Event when I click the link and display the Event's information on screen.

The process works like this:

  • user clicks the link
  • the app receives the url and extracts the event_id
  • with the event_id the app retrieves the Event's information
  • the app saves that information in local storage
  • the app sends a POST request letting the server know that a new user (me) has joined the event
  • the app displays the retrieved Event's information to the user

When the app sends the POST request to join the event, it sends the current_user's id, which is handled by the backend (I'm using Parse with Facebook login). This means that all the user authentication is handled by Gateways (with Parse the current_user's id comes in the form of PFUser, but with some other implementation it could be a String, so it must be handled by Gateway's).

My question is, should this whole interaction (joining the Event) be handled by a Gateway or by an Interactor?

  • To me it seems more logical that the Interactor should handle all that process:
    1. retrieving information with the event_id
    2. adding the current_user to the Event
    3. calling the Gateway to save the Event locally)

      But if it is handled by an Interactor, it means that this Interactor will need knowledge about PFUser (if I'm using Parse), and will have to change it's implementation if I stop using Parse (which I will).
  • If it is handled by a Gateway, it means that the Interactor will just be forwarding the join call to the Gateway
    (joinEventInteractor.join(eventId: String, callback: () -> ()) { eventGateway.join(eventId, callback: callback) }).
Jesse
  • 3,243
  • 1
  • 22
  • 29
Rodrigo Ruiz
  • 4,248
  • 6
  • 43
  • 75

1 Answers1

1

Your Gateway Should not have any business logic keep your logic inside inter-actors and deal with gateway as boundaries only , from it name it's gateway it should point inward to your inter-actor only , in case you add any logic their then you violate Single Responsibility Principle

EffectCode
  • 21
  • 1
  • 5