A TabBar with two ViewControllers one to list Users and other to list Animals using TableView

About this project

Scope

This project contains a TabBar with two ViewControllers one to list Users and other to list Animals using TableView. Project fetches list of Users and Animals from two remote APIs. Pull to refresh can be use to update the lists. If an item gets tap in any of the list then detail screen appears respectively.

What’s interesting?

Interesting part in this project is it’s Ploymorphic and reuseable code to illustrate separation of concerns and reuseability.

How ?

If you review the code you’ll find only single UITableViewController being used to show Users and Animals data without any boolean or if/else condition to know which list is currently showing, which object’s data to render in cell, which API to call on Pull to referesh and which ViewController to navigate by cell tap. All the logic and dependencies being injected from out side at the time of composition so it is fully independent and can be reused with any ViewController to show list with same kind of cell.

Other noticeable thing is the data layer where data being consumed in Ploymorphic way and ListViewModel doen’t know from where it is loading the data, data can be loaded from the remote source or from the local source without changing the code in ViewModel as ViewModel is also independent from specific context. This approach makes the code more maintainable and extendable.

GitHub

View Github