JungIn Choi
03/31/2021, 11:48 AMDay19
• Halfway through Lesson5
◦ Application architecture, Separation of Concerns design principle
▪︎ Limitation of using onSavedInstanceState - 1) require extra code to store the state in the bundle & the logic to retrieve the state 2) size of bundle is limited
▪︎ (Simplified) MVVM
• UI Controller (activity/fragment) - Display views. Handle OS event(ex. capture user keyboard input). Notify View Model that OS event has happened
• View Model - Abstract class that holds and prepares data needed for the UI. Contain instance of LiveData. Survives configuration changes. No(less?) size restriction. Should not contain references to activity/fragment/view
• Live Data - observable data holder class that is lifecycle-aware
◦ Observer pattern - Observers “watch” the subject. When event causes subject’s status change, subject notifies observers. (In this case, Live Data is the subject and UI controllers are the observers.)
▪︎ Benefits
• Organized, Easier to debug, Fewer lifecycle issues, Modular
• Faster and easier testing (since ViewModel contains no references to activities, fragments, or views)
◦ (androidTest - heavy. require emulating android framework, test - doesn’t require emulating)
Self-Comment
• It is quite hard to concentrate after the pass-day 🤔 Hope I can concentrate on something at certain time whenever I want to. That is the superpower I really want.. Felt quite depressed that I wasn’t that productive enough today, but anyways it’s better doing than not doing so.
Goals Tomorrow
• Finish lesson 5
• BLE research (googling time)Bryan L
03/31/2021, 8:15 PMJungIn Choi
04/01/2021, 3:30 AM