GENERIC-7: Take full advantage of libraries. Do not try to reinvent the wheel and loose time by implementing boilerplate code. Focus on what makes your app stand out from the rest and delegate what is left to libraries.


Description

Taking full advantage of libraries does not only save time, but could also be an improvement of your own implementation. Since multiple users could have been working on this implementation and many hands make light work. However do check the ratings of the library before using it. Or dive into the code of the library. This way you can see that you are working with high quality and bug free code.

Example

We created a simple MVVM example. This example uses RxJava. Which is a library for creating and receiving asynchronous calls by creating Observers and Observables.

In the getContributorList() method, we actually perform multiple API requests. myAPI.getRepositories() returns the Repositories from my github account. Then .flatMapIterable(x -> x) flattens a stream of iterables. Then for each repository, we fetch the contributors, and sort them based on the amount of contributions.

If we had to write this code without RxJava, we would end up with a for loop within two nested callbacks. Which would lead to ugly code.

Checkout the RXJava documentation to understand more about Observers and Observables

Check out the MVVM example to view the complete repository.