Difference Between Dagger and ButterKnife Android

Can anyone point out the difference between a dagger and a butterfly? I know that Butterknife is an injection library, and a dagger is an addiction injection library. But the online documentation seems a little overhead to me. According to Butterknife documentation, you can inject without activity, which is what a dagger does? Or didn’t I understand something?

http://square.imtqy.com/dagger/

http://jakewharton.imtqy.com/butterknife/

+61
android dagger butterknife
Dec 29 '13 at 1:13
source share
5 answers

ButterKnife is for input submissions only. A non-injection injection simply means that you can provide your own view root to introduce views from (for example, using manually-inflated views, etc.). The dagger is a little harder. It can enter anything you like if you specify Module - a class that satisfies these dependencies (as an alternative, you can use the constructor injection).

As the bottom line - I would say that ButterKnife helps you avoid all this code template for creating views (aka (TextView)findViewById(R.id.some_text_view); ). Nothing more. Under the hood, he is still doing all this boring code. So this is not really an injection ..

It's also worth mentioning that Jake Wharton is one of the developers for both of these cool libraries :)

Here are some useful links:

GitHub Dagger Design Draft

Introducing the Dagger at Devoxx (Jake Wharton)

Dagger contrast with dagger

Not many useful ButterKnife links. It’s really simple and straight forward, so I hope you don’t need to

+88
Dec 29 '13 at 1:49 on
source share

Here is a link to the Buterknife documentation. It is very simple. However, the documentation does not say, but the design of Butter Knife implies that you can also use Butter Knife in custom views. Just replace "this" with "context" or "getContext" to determine the scope.

Link: http://jakewharton.imtqy.com/butterknife/

I combine Butter Knife, parcelable and easyAdapter to view the list in my project. The reason is less conditional and with faster and cleaner packaging. Therefore, if you have many ListViews, I recommend this approach.

References:

https://github.com/johncarl81/parceler

https://github.com/ribot/easy-adapter

+4
Apr 22 '14 at 8:59
source share

The difference is quite simple: An oil knife looks like a dagger only infinitely less sharply.
As indicated in the documentation.

+4
Apr 25 '15 at 21:38
source share

@JakeWharton partially responds to a comment:

TL; DR: They complement each other. Use Butterknife for injection species, dagger for the rest.

If you use the Dagger to try to introduce the performances, you will have a very bad time :) Try to remember Butter Knife as a means of attaching views and not injections. I just called it an injection because all RoboGuice Revolutors complained about the lack of a “view injection,” with a dagger. This is not an injection. As the answer mentions, this is just a way to reduce the pattern. Under the hood, it's just calling findViewById, just like you!

+3
Jun 19 '15 at 11:27
source share

ButterKnife was created to simplify the registration of click listeners and reduce the pattern provided by findViewById() calls.

Dagger and Dagger2 - injection systems depending on the general purpose.

Ignore the text in Guice and MVVM and read Dependency Injection and The Android Way . This largely answers what the dagger should do and simplify.

https://spring.io/blog/2011/08/26/clean-code-in-android-applications

0
Apr 07 '16 at 19:16
source share



All Articles