Skip to main content
David Cruz Anaya

David Cruz Anaya

Senior Android & Kotlin Multiplatform Engineer

  • Home
  • About
  • Portfolio
  • Book
  • Speaking
  • Blog
  • Flashcards
  • Nomad Life
  • Contact
Visit Vectencia Shop

Follow Me

Privacy Policy

2014 - 2026 © davthecoder is trading as Vectencia Ltd.

davthecoder
davthecoder.com
davthecoder × Vectencia
🗄️

Room for Error

Find the bugs in each code snippet

Booking History DAO2 P0s3 total
1/8
1@Dao
2interface BookingDao {
3 @Query("SELECT * FROM bookings ORDER BY check_in DESC")
4 fun getAll(): List<Booking>
5
6 @Query("SELECT * FROM bookings WHERE id = :id")
7 fun getById(id: String): Booking?
8
9 @Insert(onConflict = OnConflictStrategy.REPLACE)
10 fun insertAll(bookings: List<Booking>)
11
12 @Delete
13 fun delete(booking: Booking)
14}
15
16class BookingHistoryViewModel(
17 private val dao: BookingDao
18) : ViewModel() {
19
20 val bookings = MutableStateFlow<List<Booking>>(emptyList())
21
22 init {
23 bookings.value = dao.getAll()
24 }
25
26 fun removeBooking(booking: Booking) {
27 dao.delete(booking)
28 bookings.value = dao.getAll()
29 }
30}
Click on the lines you think have bugsFound 0 of 3
←→NavigateAShow remainingRReset
🎯Bug Formula: What's wrong → What breaks for the user → The fix → The trade-off
Skip to main content
David Cruz Anaya

David Cruz Anaya

Senior Android & Kotlin Multiplatform Engineer

  • Home
  • About
  • Portfolio
  • Book
  • Speaking
  • Blog
  • Flashcards
  • Nomad Life
  • Contact
Visit Vectencia Shop

Follow Me

Privacy Policy

2014 - 2026 © davthecoder is trading as Vectencia Ltd.

davthecoder
davthecoder.com
davthecoder × Vectencia
🗄️

Room for Error

Find the bugs in each code snippet

Booking History DAO2 P0s3 total
1/8
1@Dao
2interface BookingDao {
3 @Query("SELECT * FROM bookings ORDER BY check_in DESC")
4 fun getAll(): List<Booking>
5
6 @Query("SELECT * FROM bookings WHERE id = :id")
7 fun getById(id: String): Booking?
8
9 @Insert(onConflict = OnConflictStrategy.REPLACE)
10 fun insertAll(bookings: List<Booking>)
11
12 @Delete
13 fun delete(booking: Booking)
14}
15
16class BookingHistoryViewModel(
17 private val dao: BookingDao
18) : ViewModel() {
19
20 val bookings = MutableStateFlow<List<Booking>>(emptyList())
21
22 init {
23 bookings.value = dao.getAll()
24 }
25
26 fun removeBooking(booking: Booking) {
27 dao.delete(booking)
28 bookings.value = dao.getAll()
29 }
30}
Click on the lines you think have bugsFound 0 of 3
←→NavigateAShow remainingRReset
🎯Bug Formula: What's wrong → What breaks for the user → The fix → The trade-off