Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to put REST API Calls in Uncle Bob's Clean Architecture?

I'm trying to use Uncle Bob's clean architecture in my android app. So, I followed this guy's great implementation based on RxAndroid, Dagger 2 for DI.
I know that to get data from data stores (Cloud or local db or disk), the Interactors (Use Case classes in the Domain layer) will invoke Repositories in the DATA Layer.

In my case, I have to execute two parallel REST API calls (Foursquare API and Google places API), then, compare the received data from each call.
Do I have to put these Retrofit calls' implementation in the Data layer or inside the Interactors in the Domain layer ?
If any external API call belongs to the data layer, what's exactly the role of interactors in Uncle Bob's approach ?

I'm new to this approach, any help is greatly appreciated!

like image 961
Rami Jemli Avatar asked Nov 19 '15 03:11

Rami Jemli


People also ask

What are gateways in clean architecture?

Usually, a gateway will be the adapter between a data source (e.g. Postgresql) and a particular Domain object (e.g. Order) In Object-Oriented languages a gateways are usually a class which implements an interface. IO is could be anything external to your application e.g. files, database or even HTTP API calls.

What is Mvvm clean architecture?

MVVM with Clean Architecture is pretty good in such cases. It goes one step further in separating the responsibilities of your code base. It clearly abstracts the logic of the actions that can be performed in your app. Note: You can combine Clean Architecture with the model-view-presenter (MVP) architecture as well.

What is a controller in clean architecture?

A controller is an object which takes the input in the form the user gives and converts it into the form required by the request model. If a user speaks to the system, then the controller's job is to convert the voice to plain English text before passing it on to the interactor.

Is clean architecture a design pattern?

Clean architecture is a category of software design pattern for software architecture that follows the concepts of clean code and implements SOLID principles.


1 Answers

i think you should call the API in data layer and then process the result in domain layer, of course if the result was independent from any framework.

and interactors was the one that orchestrate the flow of data to and from the entities. (http://fernandocejas.com/2014/09/03/architecting-android-the-clean-way/)

like image 62
surya Avatar answered Sep 30 '22 23:09

surya