À l'automne dernier, nous avons eu la chance de développer une nouvelle app pour un de nos clients en partant de zéro.
L'objectif ? Créer une application minimale à mettre entre les mains de dizaines de beta testeurs, en 8 semaines et avec 2 développeurs. Partant d'une feuille blanche, nous avons pu mettre en œuvre les dernières avancées de la stack Android sans être contraints par l'existant.
Développeurs débutants comme expérimentés, vous repartirez de ce talk avec nos apprentissages clés sur l'architecture ainsi que sur les bibliothèques et astuces pour faciliter la maintenance et la stabilité de l'application. En bonus, nous répondrons à la question : "Une app full-compose, est-ce que c'est cool ?"
Unlocking the Future of AI Agents with Large Language Models
Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023
1. Nicolas HAAN - 24/01/2023
Comment développer une
application Android en 8 semaines ?
2. BAM en quelques mots
• 120 experts du développement mobile
• 3 domaines d’expertise (Développement,
Produit et design)
• + 150 projets (UEFA, TF1, URGO, Pass
Culture)
• 2 bureaux en France (Paris et Nantes)
6. The project
• 2 developers, 8 weeks
• A finished MVP, not a POC
• State of the art technical stack,
architecture and testing strategy
• A code base ready to taken over
• A new app from scratch
15. FeatureScreen
FeatureViewModel
FeatureUseCase FeatureRepository
FeatureDataSource
ApiService
Transformer le state
exposé par le VM en
vues affichables,
récupérer les actions
utilisateur
aggrégation des données des
UseCase pour construire le state
de l'écran,
récupérer les évènements de la
Vue et les dispatcher vers les
UseCases
Implémentation des règles
métiers, agrégations des
sources de données,
abstraction des repositories
Single Source of Truth de
la donnée, règles métiers
du cache et de la
persistence
abstraction de
l'implémentation de la
datasource, préparation
des paramètres des WS,
mapping Dto <-> Domain
appel réseau, parsing
des JSON, remontée
des erreurs
16. Architecture
• Strict separation of concern
• Heavy modularisation (~22 modules for 5 screens)
• Confident that it will scale well and can be taken over
18. Groovy or KTS?
KTS promises
• Available since Android Gradle Plugin 4.1.0 (August 2020)
• The Kotlin syntax we all know and love available for Gradle!
• Autocompletion and type safety in Gradle
• The future of Gradle configuration files
19. Groovy or KTS?
• In 2022, templates are still using Groovy, even in Flamingo
• Manual migration
• Autocompletion not really useful in day to day use
• Not all libraries and open source projects have adopted it
22. Sharing build logic
"Historical method"
subprojects {
tasks.withType(Test::class.java) {
// ...
}
}
allprojects {
repositories {
// ..
}
apply(plugin = "jacoco")
jacoco {
toolVersion = "0.8.7"
}
}
• Using subprojects
and allprojects
closures
• Not very flexible
• Not explicit from a
module point of view
23. Sharing build logic
modular gradle files
apply from: "$rootDir/dependencies.gradle"
apply from: "$rootDir/gradle/baseFeature.gradle"
apply from: "$rootDir/gradle/flavors.gradle"
• doesn't scale well
• Doesn't work well with
KTS (see here and here)
24. Sharing build logic
Convention plugin
• create convention
plugins to be applied to
relevant modules
• There can be several
modular and
composable plugins
• Plugins are explicitly
applied to each module
buildSrc
androidBase.kts
flavors.kts
core/moduleX
...
domain/moduleY
39. RefreshVersions
Other features
• Support gradle plugins versions as well
• RefreshVersionsBot (~Dependabot)
• Support for Gradle VersionCatalog
• Migration still works after initial migration!
dependencies {
implementation(AndroidX.compose.ui)
implementation(AndroidX.compose.ui.toolingPreview)
implementation(AndroidX.compose.material3)
implementation("com.google.accompanist:accompanist-webview:0.28.0")
}
40. RefreshVersions
Other features
• Support gradle plugins versions as well
• RefreshVersionsBot (~Dependabot)
• Support for Gradle VersionCatalog
• Migration still works after initial migration!
dependencies {
implementation(AndroidX.compose.ui)
implementation(AndroidX.compose.ui.toolingPreview)
implementation(AndroidX.compose.material3)
implementation(libs.accompanist.webview)
}
41. New Gradle features and trends since 3~4 years
• Kotlin script (KTS)
• Convention plugins
• Convention plugins (explicit)
• pluginManagement { } block
• dependencyResolutionManagement { } block
• Version catalog
+ modularisation
+ third party libraries 🤯
43. Unit testing
Common issues
• fragile tests
• many test doubles ("mocks") to implement
• testing private methods
• testing behaviours (implementations)
• Unit tests different from acceptance tests
• Should I test pass-through classes?
45. Outside-In Strategy
Testing each class in isolation
FeatureScreen
FeatureViewModel
FeatureUseCase FeatureRepository
FeatureDataSource
ApiService
MockWebServer
Unit tests
49. OpenAPI
• The specification used by Swagger tools
• Describes the API (endpoints, objects...)
• Can be used as a contract between the
backend and the frontend
• Can be used to generate the code of the
client and/or the server
51. OpenAPI Generator
spec.json
OpenAPI Generator
/**
* Tweet delete by Tweet ID
* Delete specified Tweet (in the path) by ID.
* @param id The ID of the Tweet to be deleted.
* @return TweetDeleteResponse
* ...
*/
fun deleteTweetById(id: kotlin.String) : TweetDeleteResponse
data class Tweet (
/* Unique identifier of this Tweet. This is returned
as a string in order to avoid complications with
languages and tools that cannot handle large integers.
*/
@Json(name = "id")
val id: kotlin.String,
/* The content of the Tweet. */
@Json(name = "text")
val text: kotlin.String,
/* Unique identifier of this User.*/
@Json(name = "author_id")
val authorId: kotlin.String? = null,
// ...
52. OpenAPI Generator
• Allows to integrate BFF updates in a blink of an eye
• Quite flexible to integrate
• see more: https://www.bam.tech/article/customize-openapi-generator-output-for-
your-android-app
54. Jetpack Compose
• Really easy to implement the client Design System
• Works really well with MVI approach
• Webviews are buggy
• Jetpack Compose navigation s*cks!