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

Android in Practice (long)

AppFoundry
February 16, 2018

Android in Practice (long)

Presented by Siebe Sysmans

AppFoundry

February 16, 2018
Tweet

More Decks by AppFoundry

Other Decks in Technology

Transcript

  1. Android in Practice
    door Siebe Sysmans

    View full-size slide

  2. Siebe Sysmans
    Android Consultant

    View full-size slide

  3. • Technische interviews
    • Stagebegeleiding
    • Begeleiden Android juniors
    • Bijleren
    • Dit

    View full-size slide

  4. • Maandag t.e.m. vrijdag → Project stand-up
    • Waar is iedereen mee bezig
    • Problemen bovenhalen op geplande tickets
    • Zijn er onverwachte blokkerende tickets?
    • Is er iemand idle en kan ergens helpen?
    • Op vrijdag via Hangouts

    View full-size slide

  5. Android Studio

    View full-size slide

  6. Postman / PAW

    View full-size slide

  7. GIT / SourceTree

    View full-size slide

  8. Confluence / JIRA

    View full-size slide

  9. TeamCity / Crashlytics Beta

    View full-size slide

  10. Android Development
    Project Structure

    View full-size slide

  11. Build variants
    • buildType en productFlavors
    • Bijvoorbeeld:
    • buildType → debug, productie, …
    • productFlavor → environment

    View full-size slide

  12. Package Structure
    • Top-level package indelen in grote logische
    blokken (database, service, ui, …)
    • 2 voornamelijke manieren voor verdere indeling
    • Per type class
    • Per Feature
    • Soms ook: per feature en type

    View full-size slide

  13. Project structure

    View full-size slide

  14. Android Development
    View Libraries

    View full-size slide

  15. Butter knife

    View full-size slide

  16. Butter knife
    • Geen findViewById(…) meer.
    • Bind views, resources, onClick, …
    • Genereert code tijdens de build

    View full-size slide

  17. Picasso / Glide

    View full-size slide

  18. Picasso / Glide
    • Gemakkelijk afbeelding laden
    • Afbeeldingen cachen
    • Afbeeldingen transformeren
    • Placeholder en error ondersteuning

    View full-size slide

  19. Android Development
    Dependency Injection Libraries

    View full-size slide

  20. Dagger2
    • Dependency injection framework
    • Loskoppeling
    • Uitbreidbaar
    • Onderhoudbaar
    • Door Google en Square

    View full-size slide

  21. Android Development
    Service Libraries

    View full-size slide

  22. OkHttp
    • Vervanging van Apache HTTP client
    • Verbetering in stabiliteit
    • Verbetering in compressie
    • Silent recovery
    • Synchroon blokkerend
    • Asynchroon met callbacks

    View full-size slide

  23. Retrofit
    • Genereert netwerkcode aan de hand van een
    simpel te schrijven Interface tijden build
    • Converters voor Gson en Jackson (json),
    SimpleXML, …, roll-your-own.
    • Synchroon blokkerend
    • Asynchroon met callbacks

    View full-size slide

  24. Android Development
    Database Libraries

    View full-size slide

  25. Database Libraries
    • Wat we willen → ORM
    • Veel libraries beschikbaar
    • ORMLite
    • GreenDao
    • DBFlow
    • SugerORM
    • (Realm)
    • …

    View full-size slide

  26. Database Libraries
    • Wat we willen → ORM
    • Veel libraries beschikbaar
    • ORMLite
    • GreenDao
    • DBFlow
    • SugerORM
    • (Realm)
    • …

    View full-size slide

  27. DBFlow
    • Elimineert boilerplate
    • Genereert code tijdens build
    • Eenvoudige API voor Insert, Select, …
    • Migratie oplossing
    • SQLite
    • Eenvoudig in combinatie met Retrofit

    View full-size slide

  28. Na development

    View full-size slide

  29. Na development
    • Peer review
    • Testing
    • Beta release
    • Release
    • Release Opvolging

    View full-size slide

  30. Peer review
    • Andere developer kijkt naar de code
    • Kijkt of de huisstijl gerespecteerd is
    • Weet ook wat er in de code zit

    View full-size slide

  31. Testing
    • Geautomatiseerd testen
    • Unit testing
    • Integratie testing
    • Developer testing
    • QA

    View full-size slide

  32. (Beta) Release
    • Build maken met release keystore
    • Goed bewaren → anders nooit meer updaten
    • Beta release naar Google+ Community
    • Beide op de Google Developer Console
    • Paar uur later beschikbaar
    • Kan ook gefaseerd (5%, 10%, …)

    View full-size slide

  33. Release Opvolging
    • Crashes en exception logs opvolgen
    • Play Store
    • Crashlytics
    • Apteligent (vroeger Crittercism)
    • Customer care
    • Analytics data bekijken

    View full-size slide

  34. Nieuwe Trends

    View full-size slide

  35. MVC
    View
    Model Controller

    View full-size slide

  36. MVP
    View
    Model Presenter

    View full-size slide

  37. MVP
    View
    Use Cases
    Business Logic
    Database
    Service
    Presenter

    View full-size slide

  38. MVP
    View
    Model Presenter
    Retrieves/stores data

    View full-size slide

  39. MVP
    View
    Model Presenter
    Retrieves/stores data
    Provides form
    atted
    data

    View full-size slide

  40. MVP
    View
    Model Presenter
    Retrieves/stores data
    Provides form
    atted
    data
    Delegates click events

    View full-size slide

  41. MVP Voordelen
    • Simpeler testen
    • Mock View en Presenter
    • Gemakkelijk te onderhouden
    • Gemakkelijk View en Presenter switchen
    • A/B test
    • Nieuwe UI iteratie
    • …

    View full-size slide

  42. MVP Nadelen
    • Complexere code
    • Meer code
    • (Maar zijn dit echt nadelen?)

    View full-size slide

  43. RXJava
    • Functional Reactive Programming
    • Zeer gemakkelijke async
    • Ideaal voor
    • Service calls
    • Database read/write
    • UI events
    • Langdurige taken
    • …

    View full-size slide

  44. RXJava
    Observable Observer
    onNext(data)
    onComplete()
    onError(error)

    View full-size slide

  45. RXJava
    Observable
    Observer
    Operator
    Operator
    Operator

    View full-size slide

  46. RXJava
    Observable
    Observer
    Observable

    View full-size slide

  47. Kotlin
    • JVM programming language
    • JetBrains
    • Verbeteringen tegenover Java
    • Extension functions
    • Single expression functions
    • Range expressions
    • String templates
    • Null-safety
    • Data classes
    • …

    View full-size slide

  48. Kotlin Syntax
    class User {
    }

    View full-size slide

  49. Kotlin Syntax
    class User(val name: String, val age: Int) {
    }
    Val siebe = User(Siebe, 26)

    View full-size slide

  50. Kotlin Syntax
    class User(val name: String, val age: Int) {
    fun canVote(): Boolean {
    return age >= 18
    }
    }
    val siebe = User(Siebe, 26)
    siebe.canVote()

    View full-size slide

  51. Kotlin - Extensions
    fun String.containsSpaces(): Boolean {
    return this.indexOf(" ") != -1
    }
    “tekst”.containsSpaces()

    View full-size slide

  52. Kotlin
    Single Expression Function & Ranges
    fun isTeenager(age) = age in 13 .. 19

    View full-size slide

  53. Kotlin - String Templates
    val i = 10
    val s = “i = $i”
    val s = "abc"
    val str = "$s.length is ${s.length}”
    // evaluates to "abc.length is 3"

    View full-size slide

  54. Kotlin - Data Classes
    data class User(val name: String = "", val age: Int = 0)
    • Genereert:
    • equals()
    • hashCode()
    • toString() —> "User(name=John, age=42)”
    • copy()
    • getters en setters

    View full-size slide

  55. Kotlin - Null Safety
    var text: String = "abc"
    text = null
    // compilation error
    val length = text.length

    View full-size slide

  56. Kotlin - Null Safety
    var text: String? = "abc"
    text = null // ok
    val length = text.length
    // error: variable ‘text' can be null
    val length = text?.length
    // typeOf(length) -> Int?

    View full-size slide

  57. Siebe Sysmans
    Android Consultant
    [email protected]
    https://github.com/appfoundry/academy-android-in-practice

    View full-size slide