Bertrand Meyer • We should divide an object’s methods into either Command or Query ◦ Commands change the state but return no value ◦ Queries return a value but never change the state
the system state ◦ Does not return the state to presentation layer • Query Stack ◦ Never change the system state ◦ Returns the presentation models to presentation layer
justified ourselves that Domain Model is complex because of Domain’s complexity • Segregation of Command and Query makes it easier to express Domain in Domain Model • CQRS lights up a new aspect of Domain
update the local storage ◦ Fetch data from API ◦ Write fetched data to the local storage • Query Models - show the latest info ◦ Retrieve the local storage ◦ Re-query when the local storage is changed
Date, val endTime: Date, … ) { fun getPeriodText(context: Context): String = context.getString(...) ... Can take Android Context since Query Domain Models concern presentation
Date, val endTime: Date, … ) { fun getPeriodText(context: Context): String = context.getString(...) ... Can take Android Context since Query Domain Models concern presentation Avoid PresentationUtils class
queries ◦ Room - LiveData, RxJava ◦ Realm - Callback, RxJava ◦ Orma - RxJava, LiveData (in the plan) • Room also supports to use original classes instead of @Entity class in @Query
to optimize JavaScript world ◦ Non-complex command models ◦ No Database • Main difference is that the app state is stored on either database or memory (Store)
Command Stack and Query Stack • The separation makes it easier to construct models since understanding of Domain is definitely changed • CQRS and Flux are relatives