Overview
The article discusses the challenges and solutions involved in rewriting Uber's Android Rider app using deep scope hierarchies. It highlights the benefits of this approach in improving application structure, reducing stale state, and enhancing engineering velocity.
What You'll Learn
1
How to implement deep scope hierarchies in Android applications
2
Why deep scope hierarchies reduce stale state in applications
3
When to apply intermediate scope layers for shared objects
Prerequisites & Requirements
- Understanding of dependency injection and scope management
- Familiarity with Dagger 2 for dependency injection(optional)
Key Questions Answered
What problems did the old Uber Rider app face with its scope hierarchy?
The old Uber Rider app struggled with issues like coupling between controllers, stale state in memory, and complex state management due to its shallow two-level scope hierarchy. These problems made it difficult to maintain and scale the application effectively.
How does the new deep scope hierarchy improve the Uber Rider app?
The new deep scope hierarchy allows for better encapsulation of objects, reducing coupling between features and minimizing stale state. This results in a more maintainable application structure and enhances developer velocity by simplifying state management.
What architectural frameworks were considered for the new Uber Rider app?
The article discusses various frameworks like MVC, VIPER, Flow, Conductor, and Scoop. Ultimately, Uber developed its own framework, RIBs, which supports deep scope hierarchies without the limitations of the other frameworks.
What are the benefits of using RIBs for the new Uber Rider app?
RIBs facilitate a decoupled architecture where scopes are not tied to views, allowing for easier management of shared objects and enhancing the flexibility of the application. This design choice supports deep nesting of scopes, which is crucial for the app's complex feature set.
Technologies & Tools
Dependency Injection
Dagger 2
Used for managing dependencies and scopes within the application.
Architecture
Ribs
Uber's internal architectural framework designed to support deep scope hierarchies.
Key Actionable Insights
1Implement deep scope hierarchies to enhance application modularity and maintainability.By structuring your application with deep scopes, you can reduce dependencies between components, making it easier to manage and scale features independently.
2Utilize intermediate scope layers for shared objects to avoid stale state issues.This approach ensures that objects only exist in memory when needed, reducing the complexity of state management and improving application performance.
3Consider developing an internal tool to automate boilerplate code generation for your architecture.This can significantly reduce the friction associated with implementing new features and maintaining consistency across your codebase.
Common Pitfalls
1
Failing to manage scope lifetimes can lead to stale state and memory leaks.
When objects remain in memory longer than necessary, it complicates state management and can introduce bugs. Ensuring that scopes are properly defined and managed is crucial for application stability.
Related Concepts
Dependency Injection
Scope Management
Architectural Patterns