SPEAKER NOTES:
Welcome to Midterm Blitz! Today every question is practice for Friday's exam. Desks in teams before we start. Pull up a blank sheet of paper for tracking scores.
SPEAKER NOTES:
Give teams 2 minutes to form. Each team needs one spokesperson. They write answers on scratch paper, then hold up/reveal on count of 3. You track on whiteboard. Approximate time: 50 minutes for full deck.
SPEAKER NOTES:
10 MC questions drawn from the practice midterm. Keep the pace fast. Reveal the answer slide immediately after teams show their answers.
SPEAKER NOTES:
Common mistake: confuse with JavaScript 'let/const'. In Kotlin, val = immutable reference, var = mutable. 'const' is only valid at top-level or in companion objects.
SPEAKER NOTES:
Award 1 point to teams who answered B. Tip: default to val, only use var when you need to change the value.
SPEAKER NOTES:
This trips up a lot of students. Rotation is a configuration change, which by default destroys and recreates the Activity. This is why ViewModels exist.
SPEAKER NOTES:
Key follow-up question to ask the class: "So what DOES survive rotation without ViewModel?" Answer: Saved instance state (Bundle), but it has size limits.
SPEAKER NOTES:
Emphasize "efficiently" β that's the key word. Column composes ALL items upfront. LazyColumn only composes what's visible.
SPEAKER NOTES:
This will absolutely be on the exam. The word "lazy" = only does work when needed.
SPEAKER NOTES:
Without remember, every recomposition reinitializes the variable to its default. remember = "keep this value alive through recompositions."
SPEAKER NOTES:
Bonus discussion: what's the difference between remember and rememberSaveable? rememberSaveable survives process death and rotation.
SPEAKER NOTES:
The format is: values-[language code]. Android uses BCP 47 language tags. Default strings live in values/, locale-specific in values-[locale]/.
SPEAKER NOTES:
You can also use region qualifiers: values-es-rMX for Mexican Spanish. The -r prefix is required for region codes.
SPEAKER NOTES:
ViewModel's MAIN job: outlive the Activity/Fragment through config changes. Secondary job: hold UI state/data. It does NOT directly do DB work (that's Repository/DAO).
SPEAKER NOTES:
Draw the architecture diagram on the board: UI β ViewModel β Repository β Room/Network. ViewModel is the buffer between UI and data.
SPEAKER NOTES:
Each collection function has one job: map=transform, filter=select, reduce=combine into one, forEach=iterate with no return. Know these cold for the exam.
SPEAKER NOTES:
Know these four cold. They will appear in the coding section. You can chain them: list.filter { it > 0 }.map { it * 2 }
SPEAKER NOTES:
The ?: is called the Elvis operator (tilt your head left β looks like Elvis's hair). It's shorthand for "if this is null, use this default instead."
SPEAKER NOTES:
Quick quiz: what does "name?.length ?: 0" return if name is null? Answer: 0. If name is "Alice"? Answer: 5.
SPEAKER NOTES:
MD3 color system: primary = most prominent. onPrimary = content ON a primary-colored surface. secondary = less prominent actions. tertiary = contrasting accent.
SPEAKER NOTES:
The naming convention: "on" prefix = what goes ON top of that color. primaryContainer = a lighter tint of primary for filled buttons.
SPEAKER NOTES:
The API is simply navController.navigate(). navigateTo() doesn't exist. goTo() and push() are from other frameworks (web router, iOS UINavigationController).
SPEAKER NOTES:
Both navigate() forms are valid β string-based and type-safe. The exam may use either. navigateUp() is preferred over popBackStack() for the "up" button in the app bar.
SPEAKER NOTES:
Round 2 is more collaborative. Give teams 60 seconds to discuss together, then cold-call a team OR let teams volunteer. Award points based on quality of answer.
SPEAKER NOTES:
Listen for: val = immutable/read-only, cannot be reassigned. var = mutable, can be reassigned. Good examples: val for navController (doesn't change), var for a counter state variable.
SPEAKER NOTES:
Award 1 pt for correct definitions, 1 pt for good examples. Full credit if they say "prefer val, only use var when needed."
SPEAKER NOTES:
Key terms to listen for: "move state up to caller", "stateless composable", "single source of truth", "reusable", "testable".
SPEAKER NOTES:
Award 1 pt for correct definition, 1 pt for 2+ reasons why it matters. The stateless composable is easier to preview, test, and reuse in different contexts.
SPEAKER NOTES:
Looking for: Created, Started, Resumed, Paused, Stopped, Destroyed. Transitions: CreatedβStarted when visible, StartedβResumed when in foreground, ResumedβPaused when dialog covers it, etc.
SPEAKER NOTES:
Award 1 pt for 4 correct states, 1 pt for 2 correct transitions. Common mistake: students say "crashes" on rotation β correct answer is Stopped β Destroyed β re-Created.
SPEAKER NOTES:
Listen for: type system separates nullable (String?) from non-nullable (String), compiler forces you to handle null, prevents NullPointerException at runtime by catching at compile time.
SPEAKER NOTES:
Award 1 pt for explaining nullable vs non-nullable, 1 pt for explaining compile-time vs runtime safety. Java has the "billion-dollar mistake" β null references.
SPEAKER NOTES:
Key distinction: implementation = included in final APK, testImplementation = only for unit tests, not shipped to users.
SPEAKER NOTES:
Award 1 pt for each correct definition. Real-world reason: no point shipping test libraries to users β it bloats the APK.
SPEAKER NOTES:
3 coding questions. Teams may discuss but each person writes their answer. Award partial credit for close answers. Full credit requires correct syntax + logic.
SPEAKER NOTES:
Answer: {"B"=2, "A"=2, "C"=1} β Wait, let me trace: 85βB, 92βA, 67βF, 78βC, 95βA. So: A=[92,95], B=[85], C=[78], F=[67]. mapValues gets size. Result: {A=2, B=1, C=1, F=1}
SPEAKER NOTES:
Award: 1 pt for correct grouping logic, 1 pt for understanding mapValues, 1 pt for correct final answer. Partial credit for close answers. This is a simplified version of the exam's processStudentGrades problem.
SPEAKER NOTES:
3 bugs: 1) Missing @Composable annotation, 2) var count = 0 should be var count by remember { mutableStateOf(0) }, 3) No check preventing count from going below 0 (decrement should be if count > 0).
SPEAKER NOTES:
Award 1 pt per correctly identified and fixed bug. Bug 1: without @Composable it won't compile. Bug 2: without remember, count resets to 0 on every recomposition (tap the button, nothing appears to happen). Bug 3: requirement says can't go below 0.
SPEAKER NOTES:
β rememberNavController, β‘ navigate, β’ arguments. These are the three most testable navigation pieces.
SPEAKER NOTES:
Award 1 pt per correct blank. Common mistake for β’: students write "backStackEntry.getString" directly, but the arguments property is a Bundle that holds the args.
SPEAKER NOTES:
Final tally. Announce winner(s). If time permits, ask the winning team: "What's one thing you're still nervous about for the exam?" β good way to surface remaining gaps.
SPEAKER NOTES:
Review the exam structure. Remind them: reference sheet is a tool, not a crutch. The process of making it is the studying.
SPEAKER NOTES:
Walk through this checklist verbally. Ask "hands up if you feel good about this." That's a quick formative assessment for you to know what to focus on in Wednesday's session.
SPEAKER NOTES:
End with energy. Wednesday is more hands-on β plan to do live coding with students at the board. Friday's exam: doors close 5 minutes after start.