Mobius is our recommended architecture for building Android applications. We also feel that it is much easier to learn Test-Driven Development by starting out to build apps using Mobius.
- Theory: Introduction to Mobius (1 hour)
- Eliminating the moving parts using functional programming
- Pure functions
- State transition diagrams
Model&Event
- Pairing Activity: The counter app state transition diagram (1 hour)
- The
update()function - Introducing the
UpdateSpecclass - Test driving the counter
update()function - Wiring the
update()function to the UI
- The
- Theory: Test-Driven Development (30 minutes)
- Principles of TDD
- YAGNI
- The red, green, and refactor cycle
- TDD as a design practice
- Recap (20 minutes)
- Key takeaways
- Reading materials for the next day
- Reflection of Day 1 and discussion around reading materials (30 minutes)
- Pairing Activity: Login Screen
update()Exercise (2 hours)- Introducing effects & effect handlers
- Login example state transition diagram
- Test driving the login update() function
- Identifying the primitive obsession code smell (Watch this)
- The “What to test?” problem
- Relationship between the number of execution paths and tests
- Test driving the
UsernameandPasswordclasses - Modeling async state transitions
- Completing the
update()function
- Pairing Activity: Materializing effects using effect handlers (1:30 hours)
- State verification vs. behavior verification
- Introduction to Mockito
- Low confidence behavior verification tests
- Writing the first effect handler
- Using the RxJava
SubtypeEffectHandler Action,Consumer, andObservableTransformer- Errors of first-class citizens
- Using
Schedulerin tests
- Pairing Activity: Introduction to Views and View Renderers (45 minutes)
- Using mockito to verify view rendering logic
- Recap (20 minutes)
- Key takeaways
- Reflection of Day 2 (30 minutes)
- Pairing Activity: Creating the shell (45 minutes)
- Wiring all the Mobius components
- Saving and restoring model state
- The
@Parcelizeannotation - Caveats of saving data using Android’s
Parcelableinterface
- Pairing Activity: Subtle bugs introduced by async operations (45 minutes)
- Handling normal flow of execution using the
init()function - Handling edge cases using the
init()function - Using the
InitSpecfor testing normal flow and edge cases
- Handling normal flow of execution using the
- Recap (20 minutes)
- Reflection of Day 3 (20 minutes)
- Individual Activity: NASA APOD Application (8 - 16 hours)
- Step 1: Drawing the state transition diagram
- Step 2: Writing the
init()theupdate()tests - Step 3: Writing Effect Handler tests
- Step 4: View and View Renderer Tests
- Step 5: Wire up the imperative shell
- Code review and addressal (1:30 hours)
- Recap (1 hour)
Effectare more closer to intention for side-effect than performing a side-effect- Representing decision making in state diagram