4gus71n / AmazonBooks

Simple code challenge

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Amazon Books

Simple code challenge. The main feature is to get a list of Book objects from an Amazon endpoint. Those books are displayed in a list.

##Architecture design The architecture is designed as an MVP using RxJava+Retrofit+Dagger. Is inspirated in Fernando Ceja's clean architecture.

###Layered architecture We have several layers, first at the bottom of all the layers we have the network layer that is basically the Retrofit layer where we have our server-side endpoints declarated in the Retrofit interface (RetrofitAmazonService). Another layer above we have the BookRepository that is an implementation of the Repository Pattern (for this case we only have the network implementation, the NetworkBookRepository but we can have several repositories implementations and grab the data from different sources, database, memory cache, etc.). Above the Repository layer we have the UseCases or Interactor, in our case we only have the GetBooksUseCases. And above that we have the MVP architecture. Only the Presenters can use the different UseCases or Interactor.

###MVP architecture The MVP is implemented using LightCycle to bind the views (Fragments, Activities or Custom Views) to the Presenters.

##Libraries and tech

  • Retroyfit: To perform the http requests.
  • RxJava: To perform the asynchronous tasks.
  • Butterknife: To void all the findViewById boilerplate code.
  • Dagger: To glue all the components toghether.
  • LightCycle: To avoid hooking Presenters into the Fragments/Activities lifecycle methods.
  • Glide: To load the images from the web.
  • Mockito/Robolectric: I made a very basic Unit Test for the view. Used Robolectric to build the Unit Test. Used Mockito to mock the Book objects.

##Notes

  • I also added a small snippet to cancel the image loading if we scroll too fast. This way we can avoid stacking up several request from images that will not be displayed.
  • This is a simplified version of the Clean Architecture, usually I'd have more modules depending in the complexity/size of the project. I also skipped some layers for example, if the project is big enought I'd separate the model layer in the server-side model objects (the ones with the Gson annotations) and in the app model classes (without any annotations and the Parcelable implementation).

##APK You can download the debug apk from here

##Screenshot alt tag

About

Simple code challenge


Languages

Language:Java 100.0%