Why Bother?
Some Android experts love data binding. Others hate it. Compared to a lot of things in Android app development, opinions of data binding are wide and varied.
Developers that love data binding seem to focus a lot on the “separation of concerns” that data binding helps to enforce. Your Java/Kotlin code can stop thinking about widget details quite so much, with a lot of that code moving to the layout resources.
Detractors point out that:
- Data binding slows down the build process, as there is more code generation that needs to go on, far more than simple view binding
- Data binding can be difficult to debug, as more code is hidden from view, buried in data binding expressions and generated classes
- Data binding adds a bit more bloat to a project, adding three libraries and these generated classes, where the user gains very little from the results — view binding is smaller
Google promotes data binding as part of the Jetpack. However, whereas some aspects of Jetpack are nearly unavoidable, data binding is optional. You can use it if you like or skip it if you like.
Prev Table of Contents Next
This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.