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

Mvvm__Compose__UTP_-_A_killer_combination_for_successful_deliveries.pdf

 Mvvm__Compose__UTP_-_A_killer_combination_for_successful_deliveries.pdf

'Nitrogenize' your project with Mvvm, Compose, UTP - A killer combination for successful deliveries
Compose took on the table a new approach to developing in Android. Besides this great new framework, large portions of our apps won’t change at all, and Unidirectional Data Flow best practices should be used.

What will change in our project? Which patterns should we adapt in our app to work with these new techs? Is my app ready to be migrated with Compose? Let's see how use this new declarative UI framework in an already structured and organised project maintaining its own design pattern architecture.
What will be the advantages and disadvantages?

Unified Test Platform (UTP), best known as project code Nitrogen, it's another fantastic tech presented this year at Google IO. Let's see together what it is, why is so useful and why we should adopt it in our app.
We will use this extensible test executor to 'nitrogenize' our UI test suite covering some UI cases in our project. Let's scale together our test suite with Gradle managed devices in parallel using new test metrics, and finally, inspecting test results and possible failures by emulator snapshots.

After this talk, you will know if your app architecture is ready for Compose, you will be ready to transform your test suite into a more reliable scalable and productive env and you will speed up the delivery and the code quality of your project.

Enrico Bruno Del Zotto

November 25, 2022
Tweet

More Decks by Enrico Bruno Del Zotto

Other Decks in Technology

Transcript

  1. Nitrogenize


    Jetpack Compose + MV(x) + UTP =


    A killer combination for succesul deliveries
    @enricobdelzotto

    View full-size slide

  2. @enricobdelzotto
    About me
    •Enrico


    •Italian


    •Android engineer


    •London based

    View full-size slide

  3. Agenda
    Compose


    Architectural patterns


    Testing

    View full-size slide

  4. @enricobdelzotto
    Android Ui Kit has been build since Sept 2008




    Old times

    View full-size slide

  5. @enricobdelzotto
    Imperative


    Explicit instruction


    The system is stupid -> You are smart


    View full-size slide

  6. @enricobdelzotto

    View full-size slide

  7. @enricobdelzotto
    Google IO 2019 : Jetpack Compose

    View full-size slide

  8. @enricobdelzotto
    Declarative


    Describe the Outcome


    The system is smart, you don’t care


    View full-size slide

  9. @enricobdelzotto
    Declarative


    View full-size slide

  10. @enricobdelzotto
    Unidirectional data flow (UDF)


    Composition vs Inheritance


    Encapsulation


    Statless vs stateful


    Composition / Re-composition


    View full-size slide

  11. @enricobdelzotto
    Unidirectional data flow (UDF)


    View full-size slide

  12. @enricobdelzotto
    Composition vs Inheritance


    View full-size slide

  13. @enricobdelzotto

    View full-size slide

  14. @enricobdelzotto
    Encapsulation


    https://developer.android.com/jetpack/compose/state

    View full-size slide

  15. @enricobdelzotto
    Statless vs stateful


    View full-size slide

  16. @enricobdelzotto
    Statless vs stateful


    LaunchedEffect


    RememberCoroutineScope


    RememberUpdatedState


    DerivedStateOf


    snapshotFlow





    https://developer.android.com/jetpack/compose/side-e
    ff
    ects

    View full-size slide

  17. @enricobdelzotto
    Observe a state and re-compose by collectAsState()


    https://developer.android.com/reference/kotlin/androidx/compose/runtime/package-summary#structuralEqualityPolicy()

    View full-size slide

  18. @enricobdelzotto

    View full-size slide

  19. @enricobdelzotto
    Re-composition


    View full-size slide

  20. @enricobdelzotto
    Compose handles re-creation intelligently


    It’s using a slot table built using gap buffers


    View full-size slide

  21. @enricobdelzotto https://medium.com/androiddevelopers/under-the-hood-of-jetpack-compose-part-2-of-2-37b2c20c6cdd

    View full-size slide

  22. @enricobdelzotto https://medium.com/androiddevelopers/under-the-hood-of-jetpack-compose-part-2-of-2-37b2c20c6cdd
    State holders


    ViewModels as source of truth


    View full-size slide

  23. @enricobdelzotto
    UDF strengths


    View full-size slide

  24. @enricobdelzotto
    MVP

    View full-size slide

  25. @enricobdelzotto https://dev.to/alyssoncs/jetpack-compose-don-t-throw-your-presenters-o
    ff
    -43fk

    View full-size slide

  26. @enricobdelzotto
    (Jetpack) MVVM

    View full-size slide

  27. @enricobdelzotto
    MVI

    View full-size slide

  28. @enricobdelzotto
    Clean architecture


    Control over ui and async events


    A predefined test structure


    Quick debugging environment

    View full-size slide

  29. @enricobdelzotto
    A predefined test structure

    View full-size slide

  30. @enricobdelzotto
    Jetpack compose testing api

    View full-size slide

  31. @enricobdelzotto
    Jetpack compose rules
    Compose test rule


    Android compose test rule

    View full-size slide

  32. @enricobdelzotto
    Jetpack compose rules

    View full-size slide

  33. @enricobdelzotto

    View full-size slide

  34. @enricobdelzotto

    View full-size slide

  35. @enricobdelzotto
    Interoperability with Espresso

    View full-size slide

  36. @enricobdelzotto
    Clean architecture


    Control over ui and async events


    A predefined test structure


    Quick run and debugging environment

    View full-size slide

  37. @enricobdelzotto https://developer.android.com/studio/preview/features

    View full-size slide

  38. @enricobdelzotto https://developer.android.com/studio/preview/features

    View full-size slide

  39. @enricobdelzotto
    Optimize performances


    -> Use espresso intents to validate your outgoing intents
    Automated test devices

    View full-size slide

  40. @enricobdelzotto

    View full-size slide

  41. @enricobdelzotto

    View full-size slide

  42. @enricobdelzotto

    View full-size slide

  43. @enricobdelzotto
    Take and save screenshot of the system if our tests
    failed.


    Warning : on depending on hw rendering, aren’t supported
    when using ATDs.
    Emulator snapshot

    View full-size slide

  44. @enricobdelzotto

    View full-size slide

  45. @enricobdelzotto

    View full-size slide

  46. @enricobdelzotto
    Clean architecture


    Control over ui and async events


    A predefined test structure


    Quick run and debugging environment
    TL;DR

    View full-size slide

  47. @enricobdelzotto

    View full-size slide

  48. @enricobdelzotto

    View full-size slide

  49. Thanks
    @enricobdelzotto

    View full-size slide