Implementing Three Android Concepts to My To-do List App

It’s as clear as the title told you. Yeap! Today my post is about a simple To-do List app that I created. Here are the glimpse of my simple app.

To-do List App (1st iteration)

Disclaimer: I won’t put any code snippet about this app in here, just the concepts. And uh-oh! I haven’t implement any functionality for the Add task yet. Hope I can write about that in another post :)

If you ever learnt about ListView in Android, I believe you’ll fine RecyclerView way better and powerful than it. RecyclerView has the ability to store large number of data while maintaining the limited number of view items. Based on its ability, it is best to use RecyclerView for displaying a large amount of scrollable data or data collections that changed based on user interaction or network events.

There are 6 components that have to be present in order to create a working RecyclerView:

  1. Data
  2. RecyclerView: the scrolling list that store the data items
  3. Layout for one item of data: a separate layout for each data item
  4. Layout Manager: handles the organisation of user interface components in a view
  5. Adapter: to connect the data with the RecyclerView
  6. ViewHolder: to contain the information of displaying one view item using the item’s layout

From the demo of to-do list app that I showed you before, here is the screenshot of the implemented RecyclerView. We can see clearly that the pink square is the layout for one item of data and the blue square is the RecyclerView itself.

As you can see, each layout of one item data consists of a to-do title, a to-do description and a check box. This layout is implemented separately and bond to the RecyclerView via the custom Adapter and custom ViewHolder. For the adapter, there are at least three functions that need to be implemented, onCreateViewHolder , getItemCount , and onBindViewHolder . For further reading and understanding the concepts and the code, please click this link.

Actually, for this homework, I don’t think I implement the MVP model pretty well since this app is too small and the data used is still dummy data and hardcoded :). However, let us discuss a bit about MVP concepts to have better understanding in implementing it in this app later on.

Model-View-Presenter Design Pattern

The concepts of MVP actually pretty simple. For every update from a model or view, the presenter will be ready to keep notifying both of them. If there is an update from view like for instance there is a user interaction, the presenter will update the model if there is a data change and vice versa.

Before jump into the story of how I implement the test for this app, let us delve more about test pyramid.

Test Pyramid

As you can see from the picture above, the test pyramid consists of unit test (base), integration test (middle), and the end-to-end test (top). The unit test is a small test that validates the app’s behaviour for one class at a time. The integration test is a medium test that validates the interaction between the modules or level of stacks in the app. And last, the end-to-end test is large test that validates the user journeys exploring the modules within the app.

Since now I already implement my app with MVP design pattern (even tho, not perfectly implemented yet :p). It really helps me to finally write unit tests! For this app, I only implement unit test for the model and presenter for getToDoList function.

To ease the unit test implementation, I utilise Mockito-Kotlin library to create test doubles like fake, mock, and stub. For better understanding about test doubles, please check out this explanation provided by Martin Fowler and this medium post by Michal Lipski for the example.

To conclude, there are three useful concepts of Android development that I applied in my To-do List App: RecyclerView, MVP, and test.

Implementing those concepts are very helpful for having better understanding on the app. Hope this post is useful for you :D!

Software Engineer | Traveler | Lifelong Learner

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store