12. ––Erik Dietrich, “How Developers Stop Learning: Rise of the Expert
Beginner”
“…in software, feedback cycles tend to be on the
order of months, if not years…It’s during the full
lifetime of a project that a developer gains
experience writing code…modifying it, testing it,
and living with previous design and architecture
decisions during maintenance phases. With
everything I’ve just described, a developer is lucky
to have a first try of less than six months…”
13. ––Erik Dietrich, “How Developers Stop Learning: Rise of the Expert
Beginner”
“…in software, feedback cycles tend to be on the
order of months, if not years…It’s during the full
lifetime of a project that a developer gains
experience writing code…modifying it, testing it,
and living with previous design and architecture
decisions during maintenance phases. With
everything I’ve just described, a developer is lucky
to have a first try of less than six months…”
14.
15.
16.
17. –Jake Wharton, “The Future of Dependency Injection with Dagger 2”
“The entire public API of Dagger 2 is right here [on
this single slide]…so the only hard part about using
Dagger 2 is really understanding the fundamentals
of dependency injection and the concept of each
one of these individual things: how you provide
dependencies, how you request dependencies, and
then the component interface of how you link the
two together.”
18. –Donn Felker
“When Dagger 1 came out it was just simpler and
then Dagger 2 [came out and] I felt like it got really
complicated”
19. –Donn Felker
“When Dagger 1 came out it was just simpler and
then Dagger 2 [came out and] I felt like it got really
complicated”
“I think there’s a shared understanding that there’s
something wrong [with Dagger 2]. Something’s not
working.”
–Kaushik Goupal
“Episode 133,” Fragmented
51. • dagger-android or boilerplate?
• If I can’t just add @Inject to the constructor, what module does this go in?
• What about @Binds vs. @Provides in Kotlin?
• Does this need to be scoped? If so, which one?
• Do I need a qualifier?
• Late-bound dependencies?
• Builder, Factory, or Assisted inject?
• Are the dependencies of this dependency in the graph? If not, 🔁
53. • dagger-android or boilerplate?
• If I can’t just add @Inject to the constructor, what module does this go in?
• What about @Binds vs. @Provides in Kotlin?
• Does this need to be scoped? If so, which one?
• Do I need a qualifier?
• Late-bound dependencies?
• Builder, Factory, or Assisted inject?
• Are the dependencies of this dependency in the graph? If not, 🔁
54. • dagger-android or boilerplate?
• If I can’t just add @Inject to the constructor, what module does this go in?
• What about @Binds vs. @Provides in Kotlin?
• Does this need to be scoped? If so, which one?
• Do I need a qualifier?
• Late-bound dependencies?
• Builder, Factory, or Assisted inject?
• Are the dependencies of this dependency in the graph? If not, 🔁
55.
56. • dagger-android or boilerplate?
• If I can’t just add @Inject to the constructor, what module does this go in?
• What about @Binds vs. @Provides in Kotlin?
• Does this need to be scoped? If so, which one?
• Do I need a qualifier?
• Late-bound dependencies?
• Builder, Factory, or Assisted inject?
• Are the dependencies of this dependency in the graph? If not, 🔁
57. • dagger-android or boilerplate?
• If I can’t just add @Inject to the constructor, what module does this go in?
• ☝, but don’t forget testing
• What about @Binds vs. @Provides in Kotlin?
• Does this need to be scoped? If so, which one?
• Do I need a qualifier?
• Late-bound dependencies?
• Builder, Factory, or Assisted inject?
• Are the dependencies of this dependency in the graph? If not, 🔁
59. public static synchronized Database getInstance(Context context,
AccountProvider accountProvider) {
sInstance = new Database();
sInstance.initialize(context, accountProvider)
return sInstance;
}
60. public static synchronized Database getInstance(Context context,
AccountProvider accountProvider) {
sInstance = new Database();
sInstance.initialize(context, accountProvider)
return sInstance;
}
61. • dagger-android or boilerplate?
• ☝, but don’t forget testing
• If I can’t just add @Inject to the constructor, what module does this go in?
• What about @Binds vs. @Provides in Kotlin?
• Does this need to be scoped? If so, which one?
• Do I need a qualifier?
• Late-bound dependencies?
• Builder, Factory, or Assisted inject?
• Are the dependencies of this dependency in the graph? If not, 🔁
62. • dagger-android or boilerplate?
• ☝, but don’t forget testing
• If I can’t just add @Inject to the constructor, what module does this go in?
• What about @Binds vs. @Provides in Kotlin?
• Does this need to be scoped? If so, which one?
• Do I need a qualifier?
• Late-bound dependencies?
• Builder, Factory, or Assisted inject?
• Do I need to inject Lazy<T> or Provides<T>?
• Are the dependencies of this dependency in the graph? If not, 🔁
72. –Martin Fowler, “Is TDD Dead?” Pt 5 ~35:00
“I’m actually always suspicious when I’m writing up
a pattern or a technique if I can’t talk about reasons
when you shouldn’t use and trade-offs against it. If I
can’t find arguments against it, then I’m worrying
that I’m not really analyzing things properly.”
86. –Uncle Bob, Principles and Patterns
“…Clearly such a restriction is draconian…if you
have tried and true modules that are concrete, but
not volatile, depending upon them is not so bad.”
99. • dagger-android or boilerplate?
• If I can’t just add @Inject to the constructor, what module does this go in?
• ☝, but don’t forget testing
• What about @Binds vs. @Provides in Kotlin?
• Does this need to be scoped? If so, which one?
• Do I need a qualifier?
• Late-bound dependencies?
• Builder, Factory, or Assisted inject?
• Do I need to inject Lazy<T> or Provides<T>?
• Are the dependencies of this dependency in the graph? If not, 🔁
100. • dagger-android or boilerplate?
• If I can’t just add @Inject to the constructor, what module does this go in?
• ☝, but don’t forget testing
• What about @Binds vs. @Provides in Kotlin?
• Does this need to be scoped? If so, which one?
• Do I need a qualifier?
• Late-bound dependencies?
• Builder, Factory, or Assisted inject?
• Do I need to inject Lazy<T> or Provides<T>?
• Are the dependencies of this dependency in the graph? If not, 🔁
104. • dagger-android or boilerplate?
• If I can’t just add @Inject to the constructor, what module does this go in?
• ☝, but don’t forget testing
• What about @Binds vs. @Provides in Kotlin?
• Does this need to be scoped? If so, which one?
• Do I need a qualifier?
• Late-bound dependencies?
• Builder, Factory, or Assisted inject?
• Do I need to inject Lazy<T> or Provides<T>?
• Are the dependencies of this dependency in the graph? If not, 🔁
105. –Joe Armstrong
“If you’re ever in a big project and you’re trying to
find out how it works and you talk to people and
they say, ‘I don’t understand how this works but
someone else understands,’ then you can be sure
that you’re in a project that’s going to go pear-
shaped”
106.
107. • dagger-android or boilerplate?
• If I can’t just add @Inject to the constructor, what module does this go in?
• ☝, but don’t forget testing
• What about @Binds vs. @Provides in Kotlin?
• Does this need to be scoped? If so, which one?
• Do I need a qualifier?
• Late-bound dependencies?
• Builder, Factory, or Assisted inject?
• Do I need to inject Lazy<T> or Provides<T>?
• Are the dependencies of this dependency in the graph? If not, 🔁
108. • dagger-android or boilerplate?
• If I can’t just add @Inject to the constructor, what module does this go in?
• ☝, but don’t forget testing
• What about @Binds vs. @Provides in Kotlin?
• Does this need to be scoped? If so, which one?
• Do I need a qualifier?
• Late-bound dependencies?
• Builder, Factory, or Assisted inject?
• Do I need to inject Lazy<T> or Provides<T>?
• Are the dependencies of this dependency in the graph? If not, 🔁
113. –Martin Fowler
“I've often heard the complaint that these kinds of
service locators are a bad thing because they aren't
testable because you can't substitute
implementations for them. Certainly you can design
them badly to get into this kind of trouble, but you
don't have to.”
115. public class MainActivity {
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((Application) getApplication())
.getBluetoothComponent()
.ble()
.startAdvertising();
}
116. • dagger-android or boilerplate?
• If I can’t just add @Inject to the constructor, what module does this go in?
• ☝, but don’t forget testing
• What about @Binds vs. @Provides in Kotlin?
• Does this need to be scoped? If so, which one?
• Do I need a qualifier?
• Late-bound dependencies?
• Builder, Factory, or Assisted inject?
• Do I need to inject Lazy<T> or Provides<T>?
• Are the dependencies of this dependency in the graph? If not, 🔁
118. @Module
abstract class ViewModelModule {
@Binds
internal abstract fun bindViewModelFactory(factory: IOSchedViewModelFactory):
ViewModelProvider.Factory
}
119.
120. –Martin Fowler, “InterfaceImplementationPair”
“This isn’t…a technique that I've ever much liked.
Using interfaces when you aren't going to have
multiple implementations is extra effort to keep
everything in sync (although good IDEs help).
Furthermore it hides the cases where you actually
do provide multiple implementations.”
123. • dagger-android or boilerplate?
• If I can’t just add @Inject to the constructor, what module does this go in?
• ☝, but don’t forget testing
• What about @Binds vs. @Provides in Kotlin?
• Does this need to be scoped? If so, which one?
• Do I need a qualifier?
• Late-bound dependencies?
• Builder, Factory, or Assisted inject?
• Do I need to inject Lazy<T> or Provides<T>?
• Are the dependencies of this dependency in the graph? If not, 🔁
142. “A common issue to deal with is how to wire
together different elements: how do you fit together
this web controller architecture with that database
interface backing when they were built by different
teams with little knowledge of each other…”
–Martin Fowler, “IoC Containers and the Dependency Injection pattern”
143. “A common issue to deal with is how to wire
together different elements: how do you fit together
this web controller architecture with that database
interface backing when they were built by different
teams with little knowledge of each other…”
–Martin Fowler, “IoC Containers and the Dependency Injection pattern”
144. –Kent Beck, “Is TDD Dead?” Pt. 1 ~21:05
“My personal practice is I mock almost nothing. If I
can’t figure out how to test efficiently with the real
stuff, I find another way of creating a feedback
loop…”
145. • dagger-android or boilerplate?
• If I can’t just add @Inject to the constructor, what module does this go in?
• ☝, but don’t forget testing
• What about @Binds vs. @Provides in Kotlin?
• Does this need to be scoped? If so, which one?
• Do I need a qualifier?
• Late-bound dependencies?
• Builder, Factory, or Assisted inject?
• Do I need to inject Lazy<T> or Provides<T>?
• Are the dependencies of this dependency in the graph? If not, 🔁
146. • dagger-android or boilerplate?
• If I can’t just add @Inject to the constructor, what module does this go in?
• ☝, but don’t forget testing
• What about @Binds vs. @Provides in Kotlin?
• Does this need to be scoped? If so, which one?
• Do I need a qualifier?
• Late-bound dependencies?
• Builder, Factory, or Assisted inject?
• Do I need to inject Lazy<T> or Provides<T>?
• Are the dependencies of this dependency in the graph? If not, 🔁