directly on FirebaseAnalytics. class ProfileViewModel() { fun onProfileLoaded() { Firebase.analytics.logEvent("viewed_profile") } } @AdamMc331 #DCSF22 5
fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) val appDependencies = (this.application as MyApp).appDependencies val analyticsTracker = appDependencies.analyticsTracker val profileViewModel = ProfileViewModel(analyticsTracker) } } @AdamMc331 #DCSF22 24
instance for our en5re applica5on lifecycle. This can be true for database connec5ons, error reporters, analy5cs trackers, and similar far reaching func5onality. @AdamMc331 #DCSF22 40
as the components using them require it. For example, a presenter only needs to stay in memory if the screen using it is visible or in the backstack, or a cache layer only for a specific screen. @AdamMc331 #DCSF22 41
the DI framework we choose, but in advanced situa;ons we should be aware of memory management and ensuring we either share or create new dependencies as necessary. @AdamMc331 #DCSF22 42
use "find usages" • Pro: Easy to refactor with IDE tooling • Con: A lot of code to write and maintain ourselves • Con: ReinvenBng the wheel @AdamMc331 #DCSF22 44
to get started • Pro: More complex situa9ons like scoping are solved for us • Con: Can feel like "magic" • Con: Harder to trace usages of dependencies @AdamMc331 #DCSF22 45
to get started • Pro: More complex situa9ons like scoping are solved for us • Con: Can feel like "magic" • Con: Harder to trace usages of dependencies • Con: Requires knowledge of DI as a concept and the tool used @AdamMc331 #DCSF22 45
dependencies at compile 8me • This can lead to increased build 8mes as complexity grows • Some DI libraries use a service locator concept to fetch dependencies at run8me @AdamMc331 #DCSF22 46
dependencies at compile 8me • This can lead to increased build 8mes as complexity grows • Some DI libraries use a service locator concept to fetch dependencies at run8me • This keeps builds consistent, but can lead to unexpected errors at run8me if our dependency graph is broken @AdamMc331 #DCSF22 46
one of the libraries out there will be up to you and your team. Chose what you are comfortable with, or what you think provides the most benefit to the size and complexity of your project. @AdamMc331 #DCSF22 47
provide support for be9er tes5ng, increasing our confidence in our products. • They also provide flexibility, and enable us to make broad changes to our product quickly. @AdamMc331 #DCSF22 48
provide support for be9er tes5ng, increasing our confidence in our products. • They also provide flexibility, and enable us to make broad changes to our product quickly. • Having a dependency management system is a huge step in ensuring las5ng success of our applica5ons that can withstand the test of 5me. @AdamMc331 #DCSF22 48