Scaling Slack’s Mobile Codebases: Modernization

In the first two posts about the Duplo initiative, we described why we decided to revamp our mobile codebases, the initial phase to clean up tech debt, and our efforts to modularize our iOS and Android codebases (post 1, post 2). In this final post, we will discuss the last theme of the Duplo initiative,…

Tracy Stampfli
15 min readadvanced
--
View Original

Overview

The article discusses Slack's initiative to modernize its mobile codebases, focusing on improving app architecture, adopting new design patterns, and enhancing developer experience. It highlights specific strategies implemented for both iOS and Android platforms, along with the results achieved through the Duplo initiative.

What You'll Learn

1

How to adopt a modular architecture in mobile applications

2

Why to implement stricter linting rules to improve code quality

3

How to leverage Combine for reactive programming in iOS

4

When to migrate to modern libraries like Moshi and WorkManager in Android

5

How to utilize Jetpack Compose for UI development in Android

Prerequisites & Requirements

  • Familiarity with mobile app development concepts
  • Experience with Swift and Kotlin programming languages

Key Questions Answered

What were the main goals of Slack's Duplo initiative?
The Duplo initiative aimed to modernize Slack's mobile codebases by improving app architecture, modularizing code, and adopting new technologies and design patterns. This effort was intended to enhance the developer experience and set the foundation for future innovations.
How did Slack modernize its iOS codebase?
Slack modernized its iOS codebase by adopting a new feature architecture based on a variant of VIPER, implementing stricter linting rules, and adopting the Combine framework for reactive programming. These changes aimed to improve code quality and developer efficiency.
What libraries did Slack replace in its Android modernization?
Slack replaced Gson with Moshi for JSON parsing, transitioned from Android Priority Job Queue to WorkManager for task scheduling, and introduced an internal library called Guinness for network API calls. These changes aimed to improve performance and maintainability.
What were the results of the Duplo initiative?
The Duplo initiative resulted in a 68% modernization of the iOS codebase and 92% modularization of the Android codebase. Additionally, CI build stability improved from 77% to 90%, and average CI Time To Merge was reduced by 64%.

Key Statistics & Figures

iOS codebase modernization percentage
68%
This percentage reflects the portion of the iOS codebase updated to modern architecture and patterns by the end of the Duplo initiative.
iOS codebase modularization percentage
81%
This indicates the extent to which the iOS codebase was modularized during the Duplo initiative.
CI build stability improvement
from 77% to 90%
This improvement in CI build stability was achieved as a direct result of the modernization efforts.
Average CI Time To Merge reduction
64%
This reduction indicates a significant decrease in the time required to merge code changes, enhancing development speed.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Programming Language
Swift
Used for iOS app development and modernization efforts.
Programming Language
Kotlin
Used for Android app development and modernization efforts.
Framework
Combine
Adopted for reactive programming in the iOS codebase.
Library
Moshi
Replaced Gson for JSON parsing in the Android codebase.
Library
Workmanager
Replaced Android Priority Job Queue for scheduling background tasks in Android.
Framework
Jetpack Compose
Explored for modern UI development in Android applications.

Key Actionable Insights

1
Implementing a modular architecture can significantly enhance code maintainability and developer productivity.
By breaking down the codebase into smaller, manageable modules, teams can work independently on features, reducing interdependencies and speeding up development cycles.
2
Adopting stricter linting rules helps in maintaining code quality and preventing anti-patterns.
As Slack experienced, enforcing linting during the migration to modern modules encouraged developers to clean up legacy code, leading to a more robust and maintainable codebase.
3
Leveraging reactive programming frameworks like Combine can streamline event handling in iOS applications.
Using Combine allows for a more declarative approach to handling asynchronous events, which can simplify code and improve readability.
4
Migrating to modern libraries can improve performance and integration with current technologies.
The transition from Gson to Moshi, for instance, not only enhanced JSON parsing speed but also improved compatibility with Kotlin, showcasing the benefits of staying up-to-date with library choices.

Common Pitfalls

1
Failing to enforce strict module dependencies can lead to circular dependencies and increased complexity.
As Slack discovered, allowing too much flexibility in module dependencies resulted in a tangled codebase, necessitating stricter rules to maintain clarity and manageability.