Challenge - 5 Problems
Clean Architecture Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Identify the correct Clean Architecture layer for UI logic
In Clean Architecture for Android, which layer should handle user interface logic such as displaying data and capturing user input?
Attempts:
2 left
💡 Hint
Think about where the app interacts directly with the user.
✗ Incorrect
The Presentation layer is responsible for UI logic, managing views and user interactions. The Domain layer handles business rules, Data layer manages data sources, and Framework layer includes external tools.
❓ ui_behavior
intermediate2:00remaining
Effect of violating Dependency Rule in Clean Architecture
What happens if the Data layer directly depends on the Presentation layer in a Clean Architecture Android app?
Attempts:
2 left
💡 Hint
Consider the direction of dependencies in Clean Architecture.
✗ Incorrect
Clean Architecture enforces that dependencies point inward, from outer layers to inner layers. If Data depends on Presentation, it creates tight coupling and makes testing and maintenance difficult.
❓ lifecycle
advanced2:00remaining
Correct lifecycle owner for ViewModel in Clean Architecture
In an Android app using Clean Architecture, which lifecycle owner should be used to scope a ViewModel in the Presentation layer?
Attempts:
2 left
💡 Hint
ViewModels are tied to UI components' lifecycles.
✗ Incorrect
ViewModels should be scoped to the Activity or Fragment lifecycle to survive configuration changes and manage UI data properly. Application lifecycle is too broad, and Domain/Data layers do not have lifecycles.
advanced
2:00remaining
Where to handle navigation logic in Clean Architecture
In Clean Architecture, where should navigation logic (e.g., moving between screens) be implemented in an Android app?
Attempts:
2 left
💡 Hint
Think about which layer controls user interactions and screen changes.
✗ Incorrect
Navigation is part of UI behavior and should be handled in the Presentation layer. Domain layer handles business rules, Data layer manages data, and Framework layer provides tools but does not contain navigation logic.
🔧 Debug
expert2:00remaining
Diagnose the cause of a runtime crash due to layer violation
An Android app using Clean Architecture crashes at runtime with a ClassCastException when the Data layer tries to cast a Presentation layer class. What is the most likely cause?
Attempts:
2 left
💡 Hint
ClassCastException often happens when layers depend on each other incorrectly.
✗ Incorrect
If the Data layer depends on Presentation classes, it breaks the Dependency Rule and can cause ClassCastException at runtime due to improper class references.