A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Feature | Guice | Dagger | ||||||||||||||||
2 | https://code.google.com/p/google-guice/ | http://square.github.io/dagger/ | |||||||||||||||||
3 | |||||||||||||||||||
4 | Library | ||||||||||||||||||
5 | Version | 3.x | 0.9.2 | ||||||||||||||||
6 | Archive Size | > 650 KB (+ plug-ins) | 55KB | ||||||||||||||||
7 | Further dependencies | few | none | ||||||||||||||||
8 | |||||||||||||||||||
9 | API | ||||||||||||||||||
10 | Methods in injector/context | 20+ | 5 | ||||||||||||||||
11 | |||||||||||||||||||
12 | Concept | ||||||||||||||||||
13 | Container model | flat instances | flat instances | ||||||||||||||||
14 | Configuration style | static + programmatic (annotation + fluent interface) | static + annotation (@Provides methods) | ||||||||||||||||
15 | Wiring style | explicit (by name and type) | explicit (by name and type) | ||||||||||||||||
16 | Wiring Transparency / Independence | no (annotations required) | no (annotations required) | ||||||||||||||||
17 | "External" code handling | indirect (requires Provider) | indirect (requires @Provides method) | ||||||||||||||||
18 | Coupling style | loose | loose | ||||||||||||||||
19 | |||||||||||||||||||
20 | Types | ||||||||||||||||||
21 | Generics support | yes (each a literal class!) | yes | ||||||||||||||||
22 | Generic type safety | compile time | compile time | ||||||||||||||||
23 | Wildcard generics | yes (explicit via literal) | no | ||||||||||||||||
24 | Primitive types handling | primitive == wrapper | primitive == wrapper | ||||||||||||||||
25 | Bind to all (generic) supertypes | no | no | ||||||||||||||||
26 | Type links | yes | yes (requires @Provides method) | ||||||||||||||||
27 | |||||||||||||||||||
28 | Injection | ||||||||||||||||||
29 | Annotation guidance | required | required | ||||||||||||||||
30 | Constructor injection | yes (requires annotations) | yes (requires annotations) | ||||||||||||||||
31 | Field injection | idiomatic (annotations) | idiomatic (annotations) | ||||||||||||||||
32 | Setter injection | yes (annotations) | no | ||||||||||||||||
33 | Factory methods | yes (annotations) | no | ||||||||||||||||
34 | Static injection | yes (annotations) | yes (annotations) | ||||||||||||||||
35 | Method interception | yes (aspects) | no | ||||||||||||||||
36 | Providers | idiomatic (annotations) | idiomatic (annotations) | ||||||||||||||||
37 | Reinjection | no (use indirection) | no (use indirection) | ||||||||||||||||
38 | Optional injection | yes (annotations) | no | ||||||||||||||||
39 | Mixed injection | yes (annotations) | no | ||||||||||||||||
40 | Post-construction hook | yes (annotations) | no | ||||||||||||||||
41 | |||||||||||||||||||
42 | Modularity | ||||||||||||||||||
43 | Arrays | no | no | ||||||||||||||||
44 | Collections | java.util (via plug-in, fluent interface) | java.util (annotations) | ||||||||||||||||
45 | Multibinds | manual explicit, loose coupled (fluent interface) | manual, explicit, loose coupled (annotations) | ||||||||||||||||
46 | Sequence of declarations | crucial | irrelevant | ||||||||||||||||
47 | |||||||||||||||||||
48 | Variants | ||||||||||||||||||
49 | Creation technique | overrides (Module classes) | overrides (Module classes) | ||||||||||||||||
50 | Perspective | combined | combined | ||||||||||||||||
51 | Composition | not combinable | not compinable | ||||||||||||||||
52 | |||||||||||||||||||
53 | Applicability Restrictiveness | ||||||||||||||||||
54 | Prinicple | local modules | local modules | ||||||||||||||||
55 | Specific package (set) | no | no | ||||||||||||||||
56 | Specific class | yes (explicit via literal) | yes | ||||||||||||||||
57 | Specific interface | no | no | ||||||||||||||||
58 | Specific parent instance | no | no | ||||||||||||||||
59 | |||||||||||||||||||
60 | Scopes | ||||||||||||||||||
61 | Default scope | injection | injection | ||||||||||||||||
62 | Custom scopes | advanced | no (use child injectors) | ||||||||||||||||
63 | Available scopes | singleton, injection (request, session via plug-in) | singleton, injection | ||||||||||||||||
64 | |||||||||||||||||||
65 | Performance | ||||||||||||||||||
66 | Bootstrapping | stated that it is fast | very fast (compile time code generation) | ||||||||||||||||
67 | Object creation | stated that it is fast | very fast (avoids reflection) | ||||||||||||||||
68 | |||||||||||||||||||
69 | Error Behavior | ||||||||||||||||||
70 | Dependency cycles | viable (proxies) | illegal | ||||||||||||||||
71 | Detection of a cyclic dependencies error | - | compile time | ||||||||||||||||
72 | Scope faults | not detected | not detected | ||||||||||||||||
73 | Ambiguous binding error | lazy | compile time | ||||||||||||||||
74 | |||||||||||||||||||
75 | Summing Up | ||||||||||||||||||
76 | Best to use for | Web apps | Android, Small Codebases, Libraries | ||||||||||||||||
77 | |||||||||||||||||||
78 | |||||||||||||||||||
79 | |||||||||||||||||||
80 | |||||||||||||||||||
81 | |||||||||||||||||||
82 | |||||||||||||||||||
83 | |||||||||||||||||||
84 | |||||||||||||||||||
85 | |||||||||||||||||||
86 | |||||||||||||||||||
87 | |||||||||||||||||||
88 | |||||||||||||||||||
89 | |||||||||||||||||||
90 | |||||||||||||||||||
91 | |||||||||||||||||||
92 | |||||||||||||||||||
93 | |||||||||||||||||||
94 | |||||||||||||||||||
95 | |||||||||||||||||||
96 | |||||||||||||||||||
97 | |||||||||||||||||||
98 | |||||||||||||||||||
99 | |||||||||||||||||||
100 |