Modularizing the Takeaway Driver Android App

Selim Furkan Seyhan
Just Eat Takeaway-tech
4 min readSep 25, 2018

Growth of feature set and team size over time make it hard to work with monolith architecture. This was the case in the Takeaway Driver Android project. We started looking for an architecture that is suitable to scale the app, reduce complexity and onboard new developers faster. In this blog post we’ll give a glimpse of why and how we started the modularization and share our experiences. We were inspired to start with the modularization after visiting droidcon Berlin 2018. Later on we’ll share some links and related posts that we used as a guide.

Why modularize?

Developing new features and maintaining existing ones can be painful in a monolith architecture. Moving towards a modular architecture will resolve complex dependencies in the project by preventing circular dependencies between modules. This, in turn, improves the app’s scalability.

Increased build speed and faster test times can be achieved because the code changes will affect only a small part of the app in a module that has to be rebuilt and tested.

Another benefit is a better understanding of how the app is structured and how it works. Developers will get to know the codebase better as they modularize the project, which will increase their productivity and effectiveness. New team members can be on-boarded faster and take on responsibility of individual features immediately.

In summary, the main pros of modularization:

  • Helps to scale the app
  • Build and test optimization
  • More efficient development
  • Faster on-boarding of new developers

Why feature modules?

After doing some research, we decided to create a module for each major feature. Each module contains the UI code, data repository, models, tests and everything else that is related to this specific feature. This serves to isolate all feature-related code in a module so that it has no dependency on other features.

The main advantages of using feature modules:

  • Working in a large team gets easier because it turns into feature sub-teams working on separate modules.
  • Having feature modules enables use of instant apps.
  • Only a single module is modified while working on a feature, resulting in less merge conflicts and faster incremental builds.
  • Modules are more independent of each other, which reduces the risk of breaking features other than the one being worked on.
App architecture with feature modules
Instant app with only 1 feature

How to modularize?

Our first suggestion is to take a deep look at the current app structure and analyse the circular dependencies within potential feature modules. The goal is to have as few dependencies as possible before starting with modularization. Here is a general roadmap for how to refactor a single module into feature modules:

  • Extract code that is commonly used by multiple features into a separate module. Hopefully these are already encapsulated in methods or classes that are reusable. Otherwise refactor them into a reusable form that doesn’t depend on any specific feature. (e.g. network, persistence, base classes, base styles/themes, shared business logic, utils etc.)
  • The rest of the refactoring can be done in small steps, i.e. modularizing a single feature at a time. Move all source code of a feature into a separate module along with tests and resources. (strings, drawables, layouts, styles etc.)
  • Start refactoring features that are actively worked on. Avoid breaking parts of the project that are working and not requiring further development.
  • If possible, don’t do further development for features on the former app architecture while a feature is being refactored into a separate module. This will help avoid painful merge conflicts as a lot of code will be moved around during refactoring.

It is easier said than done but we believe that the benefits of modularization outweigh the effort for a project with multiple independent features.

We recommend these links for further reading:

Modularization — how hard can it be? (droidcon Berlin 2018) by Elin Nilsson from Spotify

How Yelp Modularized the Android App by Sanae Rosen from Yelp

App Modularization and Module Lazy-Loading by Mona Huang from Instagram

The Build Side of Android App (droidcon Berlin 2018) by Boris Farber & Nikita Kozlov

This blog post was written together with Daniel R.

Let us know what you think, drop a comment below! Also make sure to check out our careers page to discover Tech jobs at Takeaway.com!:wave:

--

--