What are the pros and cons of android data-binding?

Question

Both of my colleague and I have experience in MVVM of Web App, while we are new to native android development. Now we have contrary opinions about android data-binding -- I'm a fan of it while he is not.

My Arguments:

  • Reduces boilerplate code which in turns brings
    • Less coupling
    • Stronger readability
  • Powerful, easy to implement custom attribute and custom view
  • Even faster than findViewById (details)

His Arguments:

  • The auto-generated .class increases app size.
  • Harder to debug

I've made some investigation but there are not many discussions about it. Now I want to collect the pros and cons of android data-binding.

Aspects of discussion include but are not limited to:

  • unit test
  • app size
  • performance
  • learning curve
  • readability
  • coupling

Show source
| android   | mvvm   | data-binding   | android-databinding   2017-01-04 12:01 1 Answers

Answers to What are the pros and cons of android data-binding? ( 1 )

  1. 2017-01-04 12:01

    I will comment on your arguments first then I will state my opinion:

    1.Remove boilerplate code - it will remove some it will just move some in the xml or it will require additional classes. So you have to be careful and balance the use of data binding.

    2.Stronger readability - depends if you are a new developer then you may find it easy to learn it but if you previously worked on android you will need extra time to learn it.

    3.Powerful - the code has more power, you can implement whatever you like in code. Think about it like this, everything you implement using data binding has a code equivalent (it might be longer and more code to write), but the revers is not valid.

    4.Even faster than findViewById - comparing the speed between these two, in my opinion is useless, you will never notice the difference, if you see some difference, then one of the implementation is wrong.

    5.Auto generated class - it's true it will increase the app size, but again only if you have tons of it it will matter. It's true that on the android dev web site they state that it's kind of bad to use libraries that create autogenerated code or annotations that will generate extra code.

    6.Hard to debug - depends, like readability, of what you are used to, heck debugging is hard either way for some problems, and you will get better by debugging not by using a different library.

    So this is pure my opinion, I've developed many apps using different libraries and different approaches, and they all had pros and cons, but what I've learn: balance everything, don't use tons of libraries, don't waste time implementing things that are implemented already and work well, don't "decouple everything", don't "couple" everything, don't use code only, don't try to "generate" everything.

    I think it's quite wrong, and you can get a wrong idea, if you ask for 'pros & cons' about some library/implementation, because usually it won't be impartial, you will get a lot of pros from somebody who used the library in a specific way and it worked and others will give you cons because they used different and it didn't work.

    So in conclusion, I think you should check what the library can do for you and what can't do for you and decide if it's good for your setup. In other words, you should decide if a library is good for you not other people ;).

Leave a reply to - What are the pros and cons of android data-binding?

◀ Go back