0

Early this year (2019), Google introduced view-binding, a new feature that allows smooth binding of UI components to data sources, just like data-binding.

I went through the documentation for view-binding and I couldn't quite find any difference between view-binding and the widely-known data-binding in terms of use-case; they seem to do the exact same thing.

Do they have separate use-cases? Where is the line drawn? Was view-binding introduced so that data-binding could be deprecated?

PS:
While drafting this question, I tried to make sure I wasn't asking an opinion-based question. I just want to understand the use-cases for both libraries.

Taslim Oseni
  • 6,086
  • 10
  • 44
  • 69

1 Answers1

0

In terms of the way they work, the major difference between them is speed.

The ViewBinding API is way faster than the DataBinding library because viewBinding does not involve annotation processing underneath. This is the major advantage of view-binding over data-binding, and also why it is considered more efficient.

However, one major thumb-down for view-binding is the fact that it does not support binding-expressions (yet).

Where is the line drawn?

Due to the difference in speed/efficiency, view-binding is preferential to data-binding for large projects. Build time would be optimal since there is no annotation processing being done under the hood.

Was view-binding introduced so that data-binding could be deprecated?

Quite frankly, it's not clear yet. But at this moment, they are two mutually exclusive libraries.

Here's an article that sheds more light on the similarities and differences.

halfer
  • 19,824
  • 17
  • 99
  • 186
Taslim Oseni
  • 6,086
  • 10
  • 44
  • 69