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
🔍

P1 Bug Hunter

Find the bugs in each code snippet

Notification Manager0 P0s3 total
1/8
1class NotificationViewModel(
2 private val context: Context,
3 private val repository: BookingRepository
4) : ViewModel() {
5
6 private val receiver = object : BroadcastReceiver() {
7 override fun onReceive(ctx: Context, intent: Intent) {
8 viewModelScope.launch {
9 val booking = repository.getActiveBooking()
10 if (booking != null) {
11 showLocalNotification(ctx, booking)
12 }
13 }
14 }
15 }
16
17 init {
18 context.registerReceiver(
19 receiver,
20 IntentFilter("BOOKING_UPDATE"),
21 Context.RECEIVER_NOT_EXPORTED
22 )
23 }
24
25 val notifications = MutableStateFlow<List<Notification>>(emptyList())
26
27 fun markRead(id: String) {
28 viewModelScope.launch {
29 repository.markNotificationRead(id)
30 notifications.update { list ->
31 list.map { if (it.id == id) it.copy(read = true) else it }
32 }
33 }
34 }
35}
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
🔍

P1 Bug Hunter

Find the bugs in each code snippet

Notification Manager0 P0s3 total
1/8
1class NotificationViewModel(
2 private val context: Context,
3 private val repository: BookingRepository
4) : ViewModel() {
5
6 private val receiver = object : BroadcastReceiver() {
7 override fun onReceive(ctx: Context, intent: Intent) {
8 viewModelScope.launch {
9 val booking = repository.getActiveBooking()
10 if (booking != null) {
11 showLocalNotification(ctx, booking)
12 }
13 }
14 }
15 }
16
17 init {
18 context.registerReceiver(
19 receiver,
20 IntentFilter("BOOKING_UPDATE"),
21 Context.RECEIVER_NOT_EXPORTED
22 )
23 }
24
25 val notifications = MutableStateFlow<List<Notification>>(emptyList())
26
27 fun markRead(id: String) {
28 viewModelScope.launch {
29 repository.markNotificationRead(id)
30 notifications.update { list ->
31 list.map { if (it.id == id) it.copy(read = true) else it }
32 }
33 }
34 }
35}
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