Groupon Carlos Palacin Rubio Dec 19, 2018

How To Maximize Android's UI Reusability: 5 Common Mistakes

Article Summary

Carlos Palacin Rubio from Groupon's Android team reveals why your "optimized" UI code is actually killing reusability. Spoiler: that single ConstraintLayout you're so proud of? It's a maintenance nightmare.

After revisiting Groupon's existing UI, the Android team identified patterns that make code readable, testable, and reusable. This deep dive exposes five common mistakes that couple UI to business logic, create monolithic layouts, and sacrifice code quality for premature optimization.

Key Takeaways

Critical Insight

Reusable Android UI requires decoupling views from business models, breaking monolithic layouts into small components, and treating UI code with the same rigor as business logic.

The article includes a practical transformation showing how breaking one complex layout into six custom views made the code self-documenting without comments.

About This Article

Problem

Groupon's Android team ran into a problem where UI views were tightly connected to backend API models. This made it hard to reuse components across different screens and meant the UI broke whenever the backend changed.

Solution

Carlos Palacin Rubio's team built UI-specific models like UserUIModel and added transformation layers between them and the views. This way, the UI didn't care about API changes or how the backend structured its data.

Impact

They broke down large XML layouts into smaller custom view components using <include> and <merge> tags. The code became self-explanatory without needing comments, and they could update shared components like ProgressOverlay in one place instead of fixing every activity that used it.