The Clean Code Talks - Don't Look For Things!
Video Statistics and Information
Channel: Google TechTalks
Views: 262,368
Rating: 4.8978724 out of 5
Keywords: google, techtalks, techtalk, engedu, talk, talks, googletechtalks, education
Id: RlfLCWKxHJ0
Channel Id: undefined
Length: 37min 57sec (2277 seconds)
Published: Fri Nov 07 2008
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.
Really great video and good insights into organizing code and DI. Makes me appreciate Dagger because it already does Providers, Factories, Builders for us and helps avoid the 'new' keyword in business logic like the speaker suggests at the end.
Most of the advice is centered on Law of Demeter which is asking only for the things you need and avoid initialization work in the constructor.
Kotlin's simpler constructor syntax helps with this.
class House(private val door: Door)
Avoiding
init{}
block with code touching requested dependencies seems like a good start for following LoD.Showing testing snippets and their problems before explaining the issue was refreshing. I hope many dagger articles on the web touched that bit to give a better picture why we need to setup Dagger which really is a bit of work and easily off-putting.
An article yesterday about Dependency Injection for beginners kicked off some heated discussion. I stumbled across this talk which does a very good job at explaining why you want to inject dependencies, and how to do it.
I remember watching these when they first came out and was impressed.
A few years later when I became an Android dev, I was surprised at the quality of the Android SDK and its programming model, considering the same organisation had produced these videos.
It's also important to note that while Misko discusses testability in this talk, the biggest advantage of proper DI comes in the form of better maintainability of the code.
Therefore, even if you don't intend to unit test in the near future, you can still claim huge benefits by using DI.