12. Let’s see the calling code
(e.g. Activity with a
ViewPager)…
14. • Pass just the meaningful info to a new adapter
• Reduce noise/kill boilerplate
• Don’t repeat ourselves
Java version
✔
✔
❌
15. Java version
• Achieved DRY but…
• Far more boilerplate than the original!
• And worse, boilerplate is in calling code rather than
hidden in implementation (anonymous inner
classes)
• Conclusion: not worth it. Stick with adapter coupled
to concrete fragments
35. Conclusion
• Reduce your (Java-imposed) tolerance to
boilerplate. It’s even more of a code smell in Kotlin!
• Lots of language tools to kill boilerplate!
• Passing functions around is new territory, be
creative
36. Matthew Clarke
Oblig twitter handle: @kiwiandroiddev
References:
https://kotlinlang.org/docs/reference/operator-
overloading.html
Thank you