“decision- making” and “designing the appropriate data structure” Which data structure should be used in a given situation? Designing a new data structure to solve your problems.
more appropriate way. Preventing duplicate elements (unless a multiset) In Kotlin/JVM Set checks are O(1) on average, while List needs O(n) checks for duplicates List → ArrayList Set → LinkedHashSet
2025 About 20% of AI-generated code still needs manual correction Due to inefficiency or framework misunderstandings. To solve these issues, we must understand the generated code, identify problems, and fix them ourselves. Strong data structure knowledge and experience with data modeling are essential for resolving such challenges.
There are classical algorithms to find cycle detection in DAG Tarjan’s SCC(Strongly connected component) Topological Sorting But, these methods can’t show an exact cycle path (using in error message). → Dagger choose BFS to detect shortest path between two nodes.
as cycle-breaking: Provider<T>, Lazy<T> Map<K, Provider<V>> (value-side provider) Why? Cycles that include providers/lazy are allowed and broken by indirection at runtime codegen. “If a well-formed graph has a cycle, it necessarily contains a Provider/Lazy; Dagger breaks it by inserting a dummy Provider and wiring around the loop.” DroidKaigi 2025
private val class constructor private val class constructor private val class constructor private val class constructor private val class constructor val HomeViewModel ( useCase GetFeed) GetFeed ( repo FeedRepository) FeedRepository ( api ApiService) ApiService ( auth AuthInterceptor) AuthInterceptor ( session SessionManager) SessionManager ( vm HomeViewModel) @Inject : @Inject : @Inject : @Inject : @Inject : @Inject : BFS - In Real World Practice
Next Predecessor Change Hit ViewModel? 0 Seed: enqueue UseCase successor [Repo] pred[Repo] = UseCase X 1 Pop Repo → successors {Api} [Api] pred[Api] = Repo X 2 Pop Api → successors {Auth} [Auth] pred[Auth] = Api X 3 Pop Auth → successors {Session} [Session] pred[Session] = Auth X 4 Pop Session → successors {VM} - pred[VM] = Session O DroidKaigi 2025
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 T extends View T ( int id) { (id mID) { (T) ; } View[] mChildren; int len mChildrenCount; (int i ; i len; i ) { View v [i]; ((v.mPrivateFlags & PFLAG_IS_ROOT_NAMESPACE) ) { v v. (id); (v ) { (T) v; } } } ; } @Override < > @IdRes == = = = < ++ = == = != protected if return this final where final for where if if null return return null findViewTraversal findViewById 0 0 ViewGroup Iterates over all children in ViewGroup For each child → calls findViewById again If child is a ViewGroup → process repeats from its first child → DFS Traversal
2025 State Tree Part of Compose Runtime State update → triggers recomposition of relevant UI Layout Tree Part of Compose UI Responsible for rendering the UI
representation of UI State Tree ≈ Virtual DOM (React) No heavy View object tree → better performance State Tree ≠ strict tree → can take other forms for further optimization
Tree Store UI relevant informations of UI Node Identity, metadata, state etc. To update only the necessary parts of the tree SlotTable Actual implementation of State Tree
Buffer Array-based data structure with pre-allocated extra space (gap) Enables efficient insert/delete in the middle (gap) No need to shift all elements each time Operations use the pre- allocated gap
9 10 @Composable = @Composable = @Composable = @Composable = @Composable : = = @Composable = @Composable : @Composable -> = = () ( ) () ( ) () ( ) () ( ) (value Int ) ( $value ) () ( ) (row RowScope.() Unit) { (Modifier. (). (vertical .dp), content row) } private fun private fun private fun private fun private fun private fun private fun A Text B Text C Text D Text E Text X Text Buttons Row fillMaxWidth padding "A" "B" "C" "D" "E(value= )" "X" 0 8 Composable Groups Example
9 10 11 12 13 @Composable = = ! fun var by if () { visible remember { ( ) } (Modifier. ( .dp)) { ( ) (); (); () (visible) { () } (); () Buttons { (onClick { visible visible }) { ( ) } } } } InsertionDemo mutableStateOf Column padding Text A B C X D E Button Text false 12 "Insertion (X at the gap)" "Toggle X" Add a new Composable in the gap
9 10 11 12 13 @Composable = = ! fun var by if () { showC remember { ( ) } (Modifier. ( .dp)) { ( ) (); () (showC) { () } (); () Buttons { (onClick { showC showC }) { ( ) } } } } BackspaceDemo mutableStateOf Column padding Text A B C D E Button Text true 12 "Backspace (remove left of gap = C)" "Toggle C" Delete a Composable
we think about building programs. Key Point Not about memorizing data structures About developing the judgment to choose the right one for the problem No direct chance to apply? → Analyze existing code Gain indirect design & decision-making experience