Carousell Jintin Oct 22, 2021

Browse Page Refactoring on Android

Article Summary

Jintin from Carousell reveals how a 3,000+ line Presenter became their team's productivity nightmare. Their solution? A strategic mix of refactoring AND rewriting that didn't require months of downtime.

The Carousell Android team faced a classic tech debt crisis: their Browse page had become a monolithic single Activity with over 10 view types, making every change risky and slow. Instead of choosing between a risky full rewrite or painful incremental refactoring, they took a hybrid approach that delivered immediate wins.

Key Takeaways

Critical Insight

By splitting large components into smaller pieces first, then evaluating each independently, the team reduced complexity while keeping the business moving forward.

The article includes specific open source libraries and code patterns that made their grid layout span size calculations dramatically simpler.

About This Article

Problem

Carousell's Browse page RecyclerView had over 10 view types all managed by one complex Adapter. The team had to manually track indices whenever they inserted or deleted items across different sections.

Solution

They switched to Google's ConcatAdapter to handle each section independently. This removed the need for manual index tracking. For single-item cases, they used SoloAdapter and MonoAdapter.

Impact

Now each Adapter manages its own data, which made the code simpler. The team could move forward with confidence on other refactoring work like migrating to Kotlin and adopting MVVM without disrupting the business.