Dependency Injection, that's the thing that Dagger2 does, right? For most of us, it's black magic. Let's look deeper how DI works. And then we better understand the frameworks that are out there. This session introduce Toothpick that was created this year and is already used by millions of users as driven a lot by engineers at Groupon.
What was their need? What's wrong with Dagger?
Toothpick was designed to bring goodies from Guice to modern mobile world. It focuses on scopes and unit testing without loosing performance as Roboguice did.
20. @PreusslerBerlin
public class Dependencies {
static Dependencies instance = new Dependencies();
public static Dependencies getInstance() {
return instance;
}
public Tracker getTracker() {
return new GoogleAnalyticsTracker();
}
…
21. @PreusslerBerlin
public class Dependencies {
static Dependencies instance = new Dependencies();
public static Dependencies getInstance() {
return instance;
}
public Tracker getTracker() {
return new GoogleAnalyticsTracker();
}
…
22. @PreusslerBerlin
public class Dependencies {
static Dependencies instance = new Dependencies();
public static Dependencies getInstance() {
return instance;
}
public Tracker getTracker() {
return new GoogleAnalyticsTracker();
}
…
A code base, one activity,
needed a tracker
Needed in in a testable way
A code base, one activity,
needed a tracker
Needed in in a testable way
A code base, one activity,
needed a tracker
Needed in in a testable way
A code base, one activity,
needed a tracker
Needed in in a testable way
A code base, one activity,
needed a tracker
Needed in in a testable way
A code base, one activity,
needed a tracker
Needed in in a testable way
Same as before
Same as before
Todo split
Show inject interface
TODO show singleton! But needs lazy loading then!
TODO in code!
Known as @Inject
Todo split
Show inject interface
TODO show singleton! But needs lazy loading then!
TODO in code!
Todo split
Show inject interface
TODO show singleton! But needs lazy loading then!
TODO in code!
Todo split
Show inject interface
TODO show singleton! But needs lazy loading then!
TODO in code!
Todo split
Show inject interface
TODO show singleton! But needs lazy loading then!
TODO in code!
Todo split
Show inject interface
TODO show singleton! But needs lazy loading then!
TODO in code!
Todo split
Show inject interface
TODO show singleton! But needs lazy loading then!
TODO in code!
Todo split
Show inject interface
TODO show singleton! But needs lazy loading then!
TODO in code!
Same as before
Same as before
Same as before
Same as before
Same as before
Same as before
Same as before
Same as before
Same as before
Same as before
RobGuice
RobGuice
Cheated a bit with some newer reflection methods
Google slide NOI
Problem google said don’t use
Relfection is slow!
Problem google said don’t use
Relfection is slow!
Problem google said don’t use
Relfection is slow!
Problem google said don’t use
Relfection is slow!
Add street figher
Not in JSR
Google slide NOI
Same!
Same!
Lets try anway
Lets try anway
Dagger is heavy weight, top down, annotation porn, compile safe, faster, not for unit tests
TP is light weight, bottom up, reduced boilerplate, runtime bases scopes, JSR conform, testing focused
Dagger is heavy weight, top down, annotation porn, compile safe, faster, not for unit tests
TP is light weight, bottom up, reduced boilerplate, runtime bases scopes, JSR conform, testing focused
Dagger is heavy weight, top down, annotation porn, compile safe, faster, not for unit tests
TP is light weight, bottom up, reduced boilerplate, runtime bases scopes, JSR conform, testing focused
Dagger is heavy weight, top down, annotation porn, compile safe, faster, not for unit tests
TP is light weight, bottom up, reduced boilerplate, runtime bases scopes, JSR conform, testing focused