Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Reactive Workflows

rjrjr
September 26, 2017

Reactive Workflows

Our MVP app is too big. Introducing the Workflow pattern to try to get it back under control. Plays well with Rx, minimizes platform-specific dependencies. Woo hoo!

https://droidcon-server.herokuapp.com/showSession/103028
https://www.youtube.com/watch?v=KjoMnsc2lPo

rjrjr

September 26, 2017
Tweet

More Decks by rjrjr

Other Decks in Technology

Transcript

  1. Nav & biz logic entangled Charge Presenter Bill Card Reader

    ChargeScreen Payment Runner cardSwiped()
  2. Nav & biz logic entangled Charge Presenter Bill Card Reader

    ChargeScreen Payment Runner setCardInfo() cardSwiped()
  3. Nav & biz logic entangled Charge Presenter Bill Card Reader

    ChargeScreen Payment Runner setCardInfo() cardSwiped() next()
  4. Nav & biz logic entangled Charge Presenter Bill Card Reader

    ChargeScreen Payment Runner setCardInfo() cardSwiped() show tip screen? next()
  5. show signature screen? Nav & biz logic entangled Charge Presenter

    Bill Card Reader ChargeScreen Payment Runner setCardInfo() cardSwiped() show tip screen? next()
  6. show signature screen? Nav & biz logic entangled Charge Presenter

    Bill Card Reader ChargeScreen Payment Runner setCardInfo() finishPayment() cardSwiped() show tip screen? next()
  7. show signature screen? Nav & biz logic entangled Charge Presenter

    Bill Card Reader ChargeScreen Payment Runner setCardInfo() finishPayment() cardSwiped() show tip screen? next()
  8. iOS even worse ViewControllers full of business logic WWAD syndrome

    • Static singletons • CoreData all the things • Undiffable XIB, Storyboard files
  9. Learned helplessness Each platform > 750,000 LOC Remember, THREE HUNDRED

    SCREENS Nearly half just in payment flow Grassroots heroics no longer practical
  10. Learned helplessness Each platform > 750,000 LOC Remember, THREE HUNDRED

    SCREENS Nearly half just in payment flow Grassroots heroics no longer practical
  11. Reclaiming the commons Make fixing things someone’s job Make success

    possible • Define the problems • Describe utopia • Declare and execute two year plan Define the problems
  12. Define the problems Edit, compile, debug loop is too slow

    The code is too complex Dependencies are too interconnected
  13. Define the problems Edit, compile, debug loop is too slow

    The code is too complex Dependencies are too interconnected Modularize: small code blocks build faster Modularize: big features from simpler parts Modularize: dependencies are a DAG
  14. Utopia's core principals Immutability is assumed Be reactive: push, don’t

    pull Natural separation of UI and business concerns Uniformity of API across platforms Uniformity Utopia
  15. “Uniformity?” Code sharing? Maybe Writing is the easy part, maintenance

    is forever Shared code is foreign code Have you considered… • Shared tests • Shared API definitions (protocol buffers) Uniformity
  16. “Uniformity?” Code sharing? Maybe Writing is the easy part, maintenance

    is forever Shared code is foreign code Have you considered… • Shared tests • Shared API definitions (protocol buffers) Uniformity
  17. Workflows and Bricks Bricks Workflows Container Business model i/o App

    logic UI modeling Rendering UI event handling View Factory Brick
  18. Workflows and Bricks Bricks Workflows Container Business model i/o App

    logic UI modeling Rendering UI event handling Platform neutral* View code View Factory Brick
  19. enum class StateOfPlay { PLAYING, VICTORY, DRAW } enum class

    MARK { EMPTY, X, O } data class Player( val id: String, val name: String )
  20. data class GameState( val id: String, val playerX: Player, val

    playerO: Player, val stateOfPlay: StateOfPlay, val grid: List<List<MARK>>, val activePlayerId: String ) enum class StateOfPlay { PLAYING, VICTORY, DRAW } enum class MARK { EMPTY, X, O } data class Player( val id: String, val name: String )
  21. class GameRunner { fun newGame(xPlayerName: String, oPlayerName: String) {} fun

    restoreGame(clientId: String) {} fun takeSquare(row: Int, col: Int) {} fun end() {} fun gameState(): Observable<GameState> {} }
  22. class GameRunner { /** @throws AssertionError if not called from

    main thread */ fun newGame(xPlayerName: String, oPlayerName: String) {} /** @throws AssertionError if not called from main thread */ fun restoreGame(clientId: String) {} /** @throws AssertionError if not called from main thread */ fun takeSquare(row: Int, col: Int) {} /** @throws AssertionError if not called from main thread */ fun end() {} fun gameState(): Observable<GameState> {} } fun newGame(xPlayerName: String, oPlayerName: String) fun restoreGame(clientId: String) class GameRunner {
  23. class GameRunner { /** @throws AssertionError if not called from

    main thread */ fun newGame(xPlayerName: String, oPlayerName: String) {} /** @throws AssertionError if not called from main thread */ fun restoreGame(clientId: String) {} /** @throws AssertionError if not called from main thread */ fun takeSquare(row: Int, col: Int) {} /** @throws AssertionError if not called from main thread */ fun end() {} fun gameState(): Observable<GameState> {} } fun newGame(xPlayerName: String, oPlayerName: String) fun restoreGame(clientId: String) class GameRunner { observeOn(mainThread()) speakerdeck.com/rjrjr/ where-the-reactive-rubber-meets-the-road
  24. class GameRunner { /** @throws AssertionError if not called from

    main thread */ fun newGame(xPlayerName: String, oPlayerName: String) {} /** @throws AssertionError if not called from main thread */ fun restoreGame(clientId: String) {} /** @throws AssertionError if not called from main thread */ fun takeSquare(row: Int, col: Int) {} /** @throws AssertionError if not called from main thread */ fun end() {} fun gameState(): Observable<GameState> {} } fun newGame(xPlayerName: String, oPlayerName: String) fun restoreGame(clientId: String) class GameRunner {
  25. class GameRunner { sealed class Command { data class NewGame(val

    xPlayer: String, val yPlayer: String): Command() data class RestoreGame(val id: String): Command() data class TakeSquare(val row: Int, val col: Int): Command() object End: Command() } fun asTransformer(): Observable.Transformer<Command, GameState> { } }
  26. class GameRunner { sealed class Command { data class NewGame(val

    xPlayer: String, val yPlayer: String): Command() data class RestoreGame(val id: String): Command() data class TakeSquare(val row: Int, val col: Int): Command() object End: Command() } fun asTransformer(): Observable.Transformer<Command, GameState> { } } search for: Dan Lew transformer
  27. Remember these things? Charge Presenter Bill ChargeScreen Payment Runner setCardInfo()

    finishPayment() next() flow.set(TipScreen) Charge View
  28. Remember these things? Charge Presenter Bill ChargeScreen Payment Runner setCardInfo()

    finishPayment() next() flow.set(TipScreen) Charge View
  29. Remember these things? Charge Presenter Bill ChargeScreen Payment Runner setCardInfo()

    finishPayment() next() flow.set(TipScreen) Charge View
  30. Remember these things? Charge Presenter Bill ChargeScreen Payment Runner setCardInfo()

    finishPayment() next() flow.set(TipScreen) Charge View
  31. Workflow as = Workflow<I, R> start(I input) Maybe<R> result() abort()

    ui driver Observable<WorkflowScreen> screen()
  32. Rhymes with “view model” /** Allows interaction with a [Workflow]

    in a particular state. */ abstract class WorkflowScreen<D, out E> protected constructor( /** Uniquely identifies this screen. */ val key: String, /** Stream of data to render this screen. */ val screenData: Observable<D>, /** Callback methods (click handlers, etc.) handled by this screen. */ val eventHandler: E )
  33. class LoginScreen( errorMessage: Observable<String>, eventHandler: Events ) : WorkflowScreen<String, Events>(KEY,

    errorMessage, eventSink) { companion object { val KEY = LoginScreen::class.name } interface Events { fun onLogin(event: SubmitLogin) } data class SubmitLogin( val email: String, val password: String ) }
  34. class LoginScreen( errorMessage: Observable<String>, eventHandler: Events ) : WorkflowScreen<String, Events>(KEY,

    errorMessage, eventSink) { companion object { val KEY = LoginScreen::class.name } interface Events { fun onLogin(event: SubmitLogin) } data class SubmitLogin( val email: String, val password: String ) }
  35. class LoginScreen( errorMessage: Observable<String>, eventHandler: Events ) : WorkflowScreen<String, Events>(KEY,

    errorMessage, eventSink) { companion object { val KEY = LoginScreen::class.name } interface Events { fun onLogin(event: SubmitLogin) } data class SubmitLogin( val email: String, val password: String ) }
  36. class LoginScreen( errorMessage: Observable<String>, eventHandler: Events ) : WorkflowScreen<String, Events>(KEY,

    errorMessage, eventSink) { companion object { val KEY = LoginScreen::class.name } interface Events { fun onLogin(event: SubmitLogin) } data class SubmitLogin( val email: String, val password: String ) }
  37. class ConfirmChargeCardOnFileScreen( screenData: Observable<ScreenData>, eventHandler: Events ) : WorkflowScreen<ScreenData, Events>(KEY,

    screenData, eventHandler) { companion object { val KEY = ConfirmChargeCardOnFileScreen::class.name } data class ScreenData( val amountDue: Money, val customerName: String, val cardNameAndNumber: String, val instrumentIndex: Int) interface Events { fun doNotChargeCardOnFile() fun chargeCardOnFile(tenderedAmount: Money, instrumentIndex: Int) }
  38. Workflow as = Workflow<I, R> start(I input) Maybe<R> result() abort()

    view model source Observable<WorkflowScreen> screen()
  39. Workflow as = Workflow<I, R> start(I input) Maybe<R> result() abort()

    view model source Observable<WorkflowScreen> screen() ✔
  40. View Factory Container Workflow as = Workflow<I, R> start(I input)

    Maybe<R> result() abort() view model source Observable<WorkflowScreen> screen() RootView ✔
  41. class AuthViewFactory : AbstractViewFactory(asList( bindLayout(LoginScreen.KEY, R.layout.login) { screen -> LoginCoordinator(screen

    as LoginScreen) }, bindLayout(AuthorizingScreen.KEY, R.layout.authorizing) { screen -> AuthorizingCoordinator(screen as AuthorizingScreen) }, bindLayout(SecondFactorScreen.KEY, R.layout.second_factor) { screen -> SecondFactorCoordinator(screen as SecondFactorScreen) } ))
  42. class LoginCoordinator(private val screen: LoginScreen) : Coordinator() { private var

    subscription: Subscription = Subscriptions.unsubscribed() override fun attach(view: View) {
  43. class LoginCoordinator(private val screen: LoginScreen) : Coordinator() { private var

    subscription: Subscription = Subscriptions.unsubscribed() override fun attach(view: View) { val error = view.findViewById<View>(R.id.login_error_message) as TextView val email = view.findViewById<View>(R.id.login_email) as EditText val password = view.findViewById<View>(R.id.login_password) as EditText val button = view.findViewById<View>(R.id.login_button) as Button
  44. class LoginCoordinator(private val screen: LoginScreen) : Coordinator() { private var

    subscription: Subscription = Subscriptions.unsubscribed() override fun attach(view: View) { val error = view.findViewById<View>(R.id.login_error_message) as TextView val email = view.findViewById<View>(R.id.login_email) as EditText val password = view.findViewById<View>(R.id.login_password) as EditText val button = view.findViewById<View>(R.id.login_button) as Button button.setOnClickListener { _ -> val event = SubmitLogin(email.text.toString(), password.text.toString()) screen.eventHandler.login(event) }
  45. class LoginCoordinator(private val screen: LoginScreen) : Coordinator() { private var

    subscription: Subscription = Subscriptions.unsubscribed() override fun attach(view: View) { val error = view.findViewById<View>(R.id.login_error_message) as TextView val email = view.findViewById<View>(R.id.login_email) as EditText val password = view.findViewById<View>(R.id.login_password) as EditText val button = view.findViewById<View>(R.id.login_button) as Button button.setOnClickListener { _ -> val event = SubmitLogin(email.text.toString(), password.text.toString()) screen.eventHandler.login(event) } subscription = screen.screenData.subscribe { error.text = it } }
  46. class LoginCoordinator(private val screen: LoginScreen) : Coordinator() { private var

    subscription: Subscription = Subscriptions.unsubscribed() override fun attach(view: View) { … } override fun detach(view: View?) { subscription.unsubscribe() }
  47. class LoginCoordinator(private val screen: LoginScreen) : Coordinator() { private var

    subscription: Subscription = Subscriptions.unsubscribed() override fun attach(view: View) { … } override fun detach(view: View?) { subscription.unsubscribe() } search for: square coordinators
  48. Workflow as = Workflow<I, R> start(I input) Maybe<R> result() abort()

    state machine Container Observable<WorkflowScreen> screen() View Factory RootView ✔
  49. Workflow as = Workflow<I, R> start(I input) Maybe<R> result() abort()

    state machine Container Observable<WorkflowScreen> screen() View Factory RootView ✔ ✔ + Square Coordinators
  50. Workflow as = Workflow<I, R> start(I input) Maybe<R> result() abort()

    state machine Container Observable<WorkflowScreen> screen() View Factory RootView ✔ ✔ + Square Coordinators
  51. class AuthWorkflow(): Workflow<Unit, String>, LoginScreen.Events, SecondFactorScreen.Events { private val currentScreen

    = BehaviorSubject.create<String>() private val loginMessage = BehaviorSubject.create("") private val authorizingMessage = BehaviorSubject.create<String>() private val secondFactorMessage = BehaviorSubject.create<String>()
  52. class AuthWorkflow(): Workflow<Unit, String>, LoginScreen.Events, SecondFactorScreen.Events { private val currentScreen

    = BehaviorSubject.create<String>() private val loginMessage = BehaviorSubject.create("") private val authorizingMessage = BehaviorSubject.create<String>() private val secondFactorMessage = BehaviorSubject.create<String>() override fun screen(): Observable<WorkflowScreen<*,*> = currentScreen.map { it -> when (it) { LoginScreen.KEY -> LoginScreen(loginMessage, this) AuthorizingScreen.KEY -> AuthorizingScreen(authorizingMessage) SecondFactorScreen.KEY -> SecondFactorScreen(secondFactorMessage, this) else -> throw IllegalArgumentException("Unknown key " + it) } }
  53. class AuthWorkflow(): Workflow<Unit, String>, LoginScreen.Events, SecondFactorScreen.Events { … override fun

    onLogin(event: LoginScreen.SubmitLogin) { stateMachine.onEvent(event) } override fun onSecondFactor(event: SecondFactorScreen.SecondFactor) { stateMachine.onEvent(event) }
  54. internal enum class State { LOGIN_PROMPT, AUTHORIZING, SECOND_FACTOR_PROMPT, DONE }

    init { stateMachine = FiniteStateMachine( onEntry(AUTHORIZING) { currentScreen.onNext(AuthorizingScreen.KEY) }, onEntry(SECOND_FACTOR_PROMPT) { currentScreen.onNext(SecondFactorScreen.KEY) },
  55. internal enum class State { LOGIN_PROMPT, AUTHORIZING, SECOND_FACTOR_PROMPT, DONE }

    init { stateMachine = FiniteStateMachine( … transition(LOGIN_PROMPT, SubmitLogin::class, AUTHORIZING) .doAction { doLogin(it) }, transition(AUTHORIZING, AuthResponse::class, LOGIN_PROMPT) .onlyIf { isLoginFailure(it) } .doAction { response -> val errorMessage = response.errorMessage loginMessage.onNext(errorMessage) },
  56. internal enum class State { LOGIN_PROMPT, AUTHORIZING, SECOND_FACTOR_PROMPT, DONE }

    init { stateMachine = FiniteStateMachine( … transition(LOGIN_PROMPT, SubmitLogin::class, AUTHORIZING) .doAction { doLogin(it) }, transition(AUTHORIZING, AuthResponse::class, LOGIN_PROMPT) .onlyIf { isLoginFailure(it) } .doAction { response -> val errorMessage = response.errorMessage loginMessage.onNext(errorMessage) }, search for: Andy Matuschak states
  57. class TicTacToeViewFactory private constructor() : AbstractViewFactory(asList( bindLayout(NewGameScreen.KEY, layout.new_game_layout ) {

    screen -> NewGameCoordinator(screen as NewGameScreen) }, bindLayout(GamePlayScreen.KEY, layout.game_play_layout ) { screen -> GamePlayCoordinator(screen as GamePlayScreen) }, bindLayout(GameOverScreen.KEY, layout.game_play_layout ) { screen -> GameOverCoordinator(screen as GameOverScreen) }, bindDialog(ConfirmQuitScreen.KEY ) { screen -> ConfirmQuitDialogFactory(screen as ConfirmQuitScreen) } ))
  58. class TicTacToeViewFactory private constructor() : AbstractViewFactory(asList( bindLayout(NewGameScreen.KEY, layout.new_game_layout ) {

    screen -> NewGameCoordinator(screen as NewGameScreen) }, bindLayout(GamePlayScreen.KEY, layout.game_play_layout ) { screen -> GamePlayCoordinator(screen as GamePlayScreen) }, bindLayout(GameOverScreen.KEY, layout.game_play_layout ) { screen -> GameOverCoordinator(screen as GameOverScreen) }, bindDialog(ConfirmQuitScreen.KEY ) { screen -> ConfirmQuitDialogFactory(screen as ConfirmQuitScreen) } ))
  59. class TicTacToeViewFactory private constructor() : AbstractViewFactory(asList( bindLayout(NewGameScreen.KEY, layout.new_game_layout ) {

    screen -> NewGameCoordinator(screen as NewGameScreen) }, bindLayout(GamePlayScreen.KEY, layout.game_play_layout ) { screen -> GamePlayCoordinator(screen as GamePlayScreen) }, bindLayout(GameOverScreen.KEY, layout.game_play_layout ) { screen -> GameOverCoordinator(screen as GameOverScreen) }, bindDialog(ConfirmQuitScreen.KEY ) { screen -> ConfirmQuitDialogFactory(screen as ConfirmQuitScreen) } ))
  60. class TicTacToeWorkflow( private val gameRunner: GameRunner ): Workflow<Unit, TicTacToeGameState>, NewGameScreen.Events,

    GamePlayScreen.Events, ConfirmQuitScreen.Events, GameOverScreen.Events { private val gameStates: Observable<TicTacToeGameState> = gameRunner.gameState().startWith(NO_GAME)
  61. class TicTacToeWorkflow( private val gameRunner: GameRunner ): Workflow<Unit, TicTacToeGameState>, NewGameScreen.Events,

    GamePlayScreen.Events, ConfirmQuitScreen.Events, GameOverScreen.Events { private val gameStates: Observable<TicTacToeGameState> = gameRunner.gameState().startWith(NO_GAME) companion object { private val FAKE_ID = UUID.randomUUID().toString() private val NO_GAME = TicTacToeGameState.newGame(FAKE_ID, Player(FAKE_ID, "X"), Player(FAKE_ID, "O")) }
  62. class TicTacToeWorkflow( private val gameRunner: GameRunner ): Workflow<Unit, TicTacToeGameState>, NewGameScreen.Events,

    GamePlayScreen.Events, ConfirmQuitScreen.Events, GameOverScreen.Events { private val gameStates: Observable<TicTacToeGameState> = gameRunner.gameState().startWith(NO_GAME) …
  63. class TicTacToeWorkflow( private val gameRunner: GameRunner ): Workflow<Unit, TicTacToeGameState>, NewGameScreen.Events,

    GamePlayScreen.Events, ConfirmQuitScreen.Events, GameOverScreen.Events { private val gameStates: Observable<TicTacToeGameState> = gameRunner.gameState().startWith(NO_GAME) private val quitting = BehaviorSubject.create(false) …
  64. class TicTacToeWorkflow( private val gameRunner: GameRunner ): Workflow<Unit, TicTacToeGameState>, NewGameScreen.Events,

    GamePlayScreen.Events, ConfirmQuitScreen.Events, GameOverScreen.Events { private val gameStates: Observable<TicTacToeGameState> = gameRunner.gameState().startWith(NO_GAME) private val quitting = BehaviorSubject.create(false) private val screen = combineLatest(gameStates, quitting, { gameState, quitting -> update(gameState, quitting) }) .replay(1) override fun screen(): Observable<WorkflowScreen<*,*>> = screen …
  65. class TicTacToeWorkflow( private val gameRunner: GameRunner ): Workflow<Unit, TicTacToeGameState>, NewGameScreen.Events,

    GamePlayScreen.Events, ConfirmQuitScreen.Events, GameOverScreen.Events { … private fun update(gameState: GameState, quitting: Boolean): WorkflowScreen<*,*> { if (quitting) return ConfirmQuitScreen(this) if (gameState == NO_GAME) NewGameScreen(this) return when (gameState.stateOfPlay) { PLAYING -> GamePlayScreen(gameStates, this) VICTORY, DRAW -> GameOverScreen(gameStates, this) } } …
  66. new CompositeWorkflow<>( // Start in the AuthWorkflow. When it finishes,

    kick off // a TicTacToe game. new WorkflowBinding<>(AuthWorkflow.class, () -> ignoreStartArg(authWorkflowProvider.get()), (composite, result) -> composite.startWorkflow( forArg(TicTacToeWorkflow.class, (Unit) UNIT))), // When a TicTacToe game ends, start another one. new WorkflowBinding<>(TicTacToeWorkflow.class, () -> ignoreStartArg(ticTacToeWorkflowProvider.get()), (composite, result) -> composite.startWorkflow( forArg(TicTacToeWorkflow.class, (Unit) UNIT))) )
  67. new CompositeWorkflow<>( // Start in the AuthWorkflow. When it finishes,

    kick off // a TicTacToe game. new WorkflowBinding<>(AuthWorkflow.class, () -> ignoreStartArg(authWorkflowProvider.get()), (composite, result) -> composite.startWorkflow( forArg(TicTacToeWorkflow.class, (Unit) UNIT))), // When a TicTacToe game ends, start another one. new WorkflowBinding<>(TicTacToeWorkflow.class, () -> ignoreStartArg(ticTacToeWorkflowProvider.get()), (composite, result) -> composite.startWorkflow( forArg(TicTacToeWorkflow.class, (Unit) UNIT))) )
  68. new CompositeWorkflow<>( // Start in the AuthWorkflow. When it finishes,

    kick off // a TicTacToe game. new WorkflowBinding<>(AuthWorkflow.class, () -> ignoreStartArg(authWorkflowProvider.get()), (composite, result) -> composite.startWorkflow( forArg(TicTacToeWorkflow.class, (Unit) UNIT))), // When a TicTacToe game ends, start another one. new WorkflowBinding<>(TicTacToeWorkflow.class, () -> ignoreStartArg(ticTacToeWorkflowProvider.get()), (composite, result) -> composite.startWorkflow( forArg(TicTacToeWorkflow.class, (Unit) UNIT))) )
  69. new CompositeWorkflow<>( // Start in the AuthWorkflow. When it finishes,

    kick off // a TicTacToe game. new WorkflowBinding<>(AuthWorkflow.class, () -> ignoreStartArg(authWorkflowProvider.get()), (composite, result) -> composite.startWorkflow( forArg(TicTacToeWorkflow.class, (Unit) UNIT))), // When a TicTacToe game ends, start another one. new WorkflowBinding<>(TicTacToeWorkflow.class, () -> ignoreStartArg(ticTacToeWorkflowProvider.get()), (composite, result) -> composite.startWorkflow( forArg(TicTacToeWorkflow.class, (Unit) UNIT))) )
  70. new CompositeWorkflow<>( // Start in the AuthWorkflow. When it finishes,

    kick off // a TicTacToe game. new WorkflowBinding<>(AuthWorkflow.class, () -> ignoreStartArg(authWorkflowProvider.get()), (composite, result) -> composite.startWorkflow( forArg(TicTacToeWorkflow.class, (Unit) UNIT))), // When a TicTacToe game ends, start another one. new WorkflowBinding<>(TicTacToeWorkflow.class, () -> ignoreStartArg(ticTacToeWorkflowProvider.get()), (composite, result) -> composite.startWorkflow( forArg(TicTacToeWorkflow.class, (Unit) UNIT))) )
  71. new CompositeWorkflow<>( // Start in the AuthWorkflow. When it finishes,

    kick off // a TicTacToe game. new WorkflowBinding<>(AuthWorkflow.class, () -> ignoreStartArg(authWorkflowProvider.get()), (composite, result) -> composite.startWorkflow( forArg(TicTacToeWorkflow.class, (Unit) UNIT))), // When a TicTacToe game ends, start another one. new WorkflowBinding<>(TicTacToeWorkflow.class, () -> ignoreStartArg(ticTacToeWorkflowProvider.get()), (composite, result) -> composite.startWorkflow( forArg(TicTacToeWorkflow.class, (Unit) UNIT))) )
  72. new CompositeWorkflow<>( // Start in the AuthWorkflow. When it finishes,

    kick off // a TicTacToe game. new WorkflowBinding<>(AuthWorkflow.class, () -> ignoreStartArg(authWorkflowProvider.get()), (composite, result) -> composite.startWorkflow( forArg(TicTacToeWorkflow.class, (Unit) UNIT))), // When a TicTacToe game ends, start another one. new WorkflowBinding<>(TicTacToeWorkflow.class, () -> ignoreStartArg(ticTacToeWorkflowProvider.get()), (composite, result) -> composite.startWorkflow( forArg(TicTacToeWorkflow.class, (Unit) UNIT))) )
  73. Step zero: make refactoring… …possible • Mock service layer •

    Robot-based UI tests (espresso, KIF) …tolerable • OkBuck for Android • CocoaPods for iOS
  74. Always be writing PSAs Design docs (everyone, all the time)

    Policy docs (a few, mostly: “write a damn design doc”) How-to guides and sample code
  75. Full disclosure Brick pattern established on both First j2Objc brick

    entering production Non-toy workflows in development on both Composite Workflow on Android Composite WorkflowScreen TBD