Full Guide to Manual Dependency Injection + Removing Dagger

  Рет қаралды 35,126

Philipp Lackner

Philipp Lackner

10 ай бұрын

In this video you'll learn how you can get rid of Dagger-Hilt and start manually injecting your dependencies to have the same advantages while minimizing build time and errors.
Secure your EARLY BIRD discount for my new testing course bundle! (just a few more days)
pl-coding.com/testing
Initial branch with Dagger:
github.com/philipplackner/Man...
Final branch with manual DI:
github.com/philipplackner/Man...

Пікірлер: 185
@PhilippLackner
@PhilippLackner 10 ай бұрын
Some clarification: I'm neither against Dagger nor completely pro manual DI. In most more complex projects Dagger provides functionality you can't easily achieve with manual DI. But in simpler projects, it's overkill in most cases. The main thing I want to show with this is that DI on Android != Dagger. DI is often overcomplicated and people think it can only be achieved with Dagger which is simply not true.
@houssemzaier
@houssemzaier 10 ай бұрын
Now I agree 👍 good clarification
@ChrisAthanas
@ChrisAthanas 10 ай бұрын
My question is how are these singletons released after they go out of scope and no longer necessary?
@paulsoja2732
@paulsoja2732 10 ай бұрын
And what about scopes?
@houssemzaier
@houssemzaier 10 ай бұрын
@@paulsoja2732 this when manual DI fails
@houssemzaier
@houssemzaier 10 ай бұрын
@@ChrisAthanas a jvm singleton is never released
@ErdemKalyoncu
@ErdemKalyoncu 10 ай бұрын
I think learning Manual DI helps you understand what is going on under the hood when you use Hilt or Koin. Very helpful video as usual. Thank you!
@hesham4744
@hesham4744 10 ай бұрын
Thank you so much for this insightful video! I was really struggling to wrap my head around Dagger and its complexities. Your video brilliantly showcases alternative ways to achieve manual dependency injection on Android, offering a fresh perspective and a sense of relief. Your clear explanations and demonstrations have made the concept crystal clear, and I'm now more confident in navigating these challenges. Your effort in simplifying this topic is truly appreciated. Keep up the great work!
@skarloti
@skarloti 10 ай бұрын
I haven't seen such a useful and well explained solution in a long time. I think most Android developers will use this approach because everything is visible and clear. For small projects written in pure Kotlin, I think it is unnecessary to use Dagger/Hilt. Thank you so much!
@mark-147
@mark-147 10 ай бұрын
Good video. As mentioned, there are some cases where third party DI makes sense. Multi module apps for example, where most modules don't have access to the Application subclass.
@FabioSangregorio-od4qv
@FabioSangregorio-od4qv 10 ай бұрын
Ths simple approach works also for other languages and contexts, I'll be using it! Thanks!
@mohamedalaa6yahoo
@mohamedalaa6yahoo 5 ай бұрын
I liked the way you use companion object cause I always run in problem of needing a singletone with a constructor, New great idea THANKS BRO 😄
@watermelon0guy
@watermelon0guy 10 ай бұрын
Thanks for video! I didn't understand why everyone was constantly using Dagger (or Hilt). After all, for small projects it would be more efficient to do it manually. This video shows where to start and how to build architecture
@rcgonzalezf
@rcgonzalezf 10 ай бұрын
For small projects build time isn't an issue, so I don't know what we're optimizing here. With Dagger+Hilt the video would have ended in minute 2, all the other 10 minutes was due to manually injecting the objects.
@torstenflammiger8444
@torstenflammiger8444 10 ай бұрын
It's about learning and understanding how things work@@rcgonzalezf
@JazzyJesterTechPing
@JazzyJesterTechPing 10 ай бұрын
Thanks, nice approach !
@vitalijuskolinko9011
@vitalijuskolinko9011 9 ай бұрын
Got used to Dagger 2 / Dagger Hilt :) This manual DI also great! I'd rather say that it is very useful for beginners to understand how Dagger works under the hood ;) 🇱🇹
@jenovas00
@jenovas00 10 ай бұрын
No do not move backwards :D Use Dagger + Hilt if you know how to use it. It just makes your life so much easier in every possible way. Manual Dependency is actually more complicated than Dagger + Hilt at this time. Dagger + Hilt allows you to easily inject into Activity, Fragment, Compose, ViewModel, Workers, View, Service, BroadcastReceivers, Alarms, Tests, where you'd need custom factories / implementations / huge singletons or god classes to do it manually.
@PhilippLackner
@PhilippLackner 10 ай бұрын
While I agree that using Dagger has some advantages over manual DI, I think it by no means belongs in every project out there. Most people think you have to use Dagger in order to achieve DI and forget about what DI is really about
@ShaqarudenGames
@ShaqarudenGames 10 ай бұрын
Koin
@ShaqarudenGames
@ShaqarudenGames 10 ай бұрын
Honestly though don’t be completely shutout from any other solution. Dagger is not the only way to do it
@marekgajda838
@marekgajda838 10 ай бұрын
Well, Koin is runtime di, just for this reason my choice is dagger/hilt
@leslied7456
@leslied7456 10 ай бұрын
I think it depends. It’s even more complicated for tiny projects, modules and features.
@tch.777
@tch.777 10 ай бұрын
Thank you Philipp you are the best 🙏🔥
@GabrielTrifa
@GabrielTrifa 5 ай бұрын
i really enjoy your videos. thanks!
@alexteodorovici_yt
@alexteodorovici_yt 9 ай бұрын
Awesome, thank you 😀
@MMateos97
@MMateos97 10 ай бұрын
The best Android related videos on KZbin 👌
@ChrisAthanas
@ChrisAthanas 10 ай бұрын
Philip shows the google android team how to explain their goofy technology so people outside the company can understand
@ojo_lali_ngaji
@ojo_lali_ngaji 10 ай бұрын
always make usefull content 🤝
@MegaAntarioGames
@MegaAntarioGames 10 ай бұрын
Seems like a good way to add DI to a KMM project.
@sanjaybhatikar
@sanjaybhatikar 10 ай бұрын
Thank you!
@yosipipi
@yosipipi 9 ай бұрын
Cool idea for a video! Also nice, for better understanding of what happens behind the scenes. Whether to really use this approach, maybe if the projcet is really small. Because once you've got more things to Inject, like 10 useCases for your viewmodel, you wouldn't want to do so every time you refer to that viewmodel. It's also not good for seperation of concerns, because it's not the screen's/activity's business what use case its viewmodel is using... But nice idea ;)
@denisgithuku8563
@denisgithuku8563 10 ай бұрын
Hi Philip this is good stuff now
@martinseal1987
@martinseal1987 10 ай бұрын
Would have been nice to speak about singletons and factories in this
@berkowk
@berkowk 3 ай бұрын
Even better would be to access an application instance in the create method which accepts extras. This way we may move context-dependent dependencies provider to application (non companion). While the ViewModel.Factory instance could be declared as a stateless object.
@senk0n
@senk0n 10 ай бұрын
what a timing, just before alpha KSP support for dagger released :D
@ChrisAthanas
@ChrisAthanas 10 ай бұрын
Annotations are so confusing and messy
@ahmadrezasariaslani4650
@ahmadrezasariaslani4650 10 ай бұрын
Nice video! How does the create() method in retrofit know it should return AuthApi? How does it read the return type of the enclosed function?
@PhilippLackner
@PhilippLackner 10 ай бұрын
The type is specified by the function return type
@karolkulbaka8577
@karolkulbaka8577 9 ай бұрын
I wasn't a big fan of koin, but koin-annotation made Hilt stop appealing to me - it's all about the configuration.
@mohamadrezamehrjou9553
@mohamadrezamehrjou9553 9 ай бұрын
Great video thank you Philipp
@ubersticks
@ubersticks 7 ай бұрын
I can hear Vasiliy applauding in the back of the room 😀
@mfs6376
@mfs6376 8 ай бұрын
Thanks for this, it was really helpful but I have a query regarding this. How to use app module to inject dependency that are async like room database. The problem is this I have used the same code for this but as soon I access that database from AppModule in my view model it throws null pointer exception. Any suggestions for that?
@MaisUmSomente
@MaisUmSomente 7 ай бұрын
Nice trick
@serlok4688
@serlok4688 9 ай бұрын
Hello Philip, would you consider selling the course prices more affordable in countries like turkey as steam does? I want to take your courses but as a student it is quite difficult for me to afford.
@riyupapa39
@riyupapa39 10 ай бұрын
Great video!!! But after learn manual DI, think again Hilt and Dagger is a good library.
@bungholici-gg5vt
@bungholici-gg5vt 10 ай бұрын
What about objects that should survive a configuration change, but should not be singletons? Use some class container with onRetainNonConfigurationInstance?
@wigs_n_roses
@wigs_n_roses 9 ай бұрын
Hi, Philipp! A question about your Testing course: in UI testing module do you explain how to test Compose UI or only traditional views? Thank you for the answer in advance! ❤
@PhilippLackner
@PhilippLackner 9 ай бұрын
It's all focused on compose 💪🏻
@wigs_n_roses
@wigs_n_roses 9 ай бұрын
@@PhilippLackner great, than I will buy!
@francoisrochefort5759
@francoisrochefort5759 10 ай бұрын
NICE!!!!!
@martinseal1987
@martinseal1987 10 ай бұрын
Just as I'm porting my java app to flutter then finding flutter isn't a great fit for what I want and moving to compose instead 😂 I hated dagger hilt and am looking for a better way
@bobandrews605
@bobandrews605 10 ай бұрын
nice video, but it would be also nice if you would use the latest stable android studio version with default settings, I initially always have problems to get your example projects running
@PhilippLackner
@PhilippLackner 10 ай бұрын
This is the latest stable version. You might need to select the correct jdk used in the project
@amarchaudhary5832
@amarchaudhary5832 9 ай бұрын
@@PhilippLackner and room version too, your clean architecture app works only on ver 2.4.1 for me :)
@eriknyk2k
@eriknyk2k 10 ай бұрын
What about Koin, it would be an alternative for you or def not?
@vladislavmelnikov5452
@vladislavmelnikov5452 10 ай бұрын
Naaah, no way, I never give up on Dagger, it is been almost 3 years and I just finally understood all his power
@ibrahimanimasahun9431
@ibrahimanimasahun9431 10 ай бұрын
Dagger/Hilt worshippers keeps saying you're reinventing the wheel, not knowing this is actually the wheel that was reinvented
@PhilippLackner
@PhilippLackner 10 ай бұрын
😂
@vibovitold
@vibovitold 10 ай бұрын
That's about as true as saying that a modern car wheel with TPMS sensors, self-healing tires and carbon fiber is a "reinvention" of the original stone age wheel.
@github.junrdev
@github.junrdev 10 ай бұрын
Just yesterday solving dagger-hilt errors,,,,,Thank you aloot
@ChrisAthanas
@ChrisAthanas 10 ай бұрын
How about the lifetime issue, where dependencies are allowed to be released when not needed?
@ChrisAthanas
@ChrisAthanas 10 ай бұрын
Not all singletons are used everywhere in the app, how is this handled with this technique? I see lazy init but what about release?
@nymexe
@nymexe 10 ай бұрын
KSP is coming, soon will have a faster processor 😉
@PhilippLackner
@PhilippLackner 10 ай бұрын
Video is already planned :D
@RishiRajxtrim
@RishiRajxtrim 10 ай бұрын
Great
@MonichGPT
@MonichGPT 6 ай бұрын
@PhilippLackner Please tell how to create viewModel without hilt annotation but still with dependencies provided by hilt? Please please please!
@milo4539
@milo4539 Ай бұрын
Did you ever find a way to reset or clear the ViewModel instance without Hilt?
@filipmanevski9872
@filipmanevski9872 9 ай бұрын
Does this work only on android apps or can it also work on KMM projects?
@trafalgarlaw3707
@trafalgarlaw3707 8 ай бұрын
Can you please do a video or a paid course where you use Dagger 2? It's still relevant to this day and is often asked in interviews
@dominicblaich
@dominicblaich 10 ай бұрын
Hmm for me it looks like the manual DI is more work then hilt. Pure Dagger is really too much, but hilt already extracted the minimum need and you just have to add these small annotations. In this example philipp showed us you could see, that you have to write more code (at least the double), especially when you have viewModels with a lot of parameters for the constructor. Even for very small projects its still less work using hilt then doing it manually^^ Also it is not necessary to use an interface.. for testing you can just use "mockk" for the objects. The only advantage for using manual DI is in my opinion the very bad compiler error messages of dagger/hilt. But when you have a bit experience, then even this errors are at some point usefull :D edit: As far as I know, its also not an good idea to use companion object for singletons. The Garbage Collector can garbage collect the static objects anytime. The chances are may not high, but this can happen. In Dagger/Hilt, the singletons are not static singletons, so they are also cannot randomly get garbage collected. Also when you really want to improve your build time, dont do manually DI but split your projects into modules. These modules can get build in parallel in really speed up you building a lot!
@nguyentu1046
@nguyentu1046 10 ай бұрын
@PhilippLackner May I know the IDE theme you are using? Thanks!
@ChrisAthanas
@ChrisAthanas 10 ай бұрын
Android studio with new ui active
@ChrisAthanas
@ChrisAthanas 10 ай бұрын
The default theme in the new ui in AS
@nguyentu1046
@nguyentu1046 9 ай бұрын
@@ChrisAthanas Thank a lot bro.
@aroxing
@aroxing 7 ай бұрын
No matter how you style it, Java is the World of Overengineering. When I started learning Kotlin I thought it was something like Python or at least Javascript but it was just a shadow of Java: patterns over patterns, libraries over libraries. Look at the DI history in Android: Manual Dependency Injection (pre-frameworks era) RoboGuice (2010) Dagger 1 (2012) Dagger 2 (2015) Google's Dagger Android (2017) Koin (2017) Hilt (2020) Koin 3 (2021) Want more? :) Here they are: Kodein ButterKnife DINJ Toothpick KodeGo Needle Guys, is this normal?:)
@vibovitold
@vibovitold 10 ай бұрын
1. Dagger may be an overkill for small projects - and it's very complex (true), even intimidating. 2. But if you find yourself creating an "AppModule" by hand... you should ask yourself: is my project really small enough not to use an industry-standard solution? 3. It's not unlike writing your own ORM. It's easy for trivial cases, but it's dangerously close to reinventing the wheel, and the infamous NIH (Not Invented Here) syndrome. 4. There are simpler ready-to-use alternatives if Dagger is too complex for your needs. Koin, for example. Very easy to set up, much more beginner-friendly than Dagger, and, well, battle-tested. There is a much greater chance of having a hidden bug, or an unhandled edge-case in your custom DI, than in Koin. 5. All this being said, here is great educational value in writing a simple DI framework yourself. It really helps to understand how DI truly works, including the concepts behind Dagger. In this sense I'm fully on board. PS. I haven't watched the full video (yet). If some of my points are acknowledged in the video, simply treat my comment as a non-polemical summary
@Zhuinden
@Zhuinden 8 ай бұрын
Just because a framework is "Google-supported" doesn't mean it's technically "industry standard". Uber has Motif, Deliveryhero has Whetstone, then there's Koin, Kodein, Toothpick, Anvil. All of these predated by Guice (which "was industry-standard" and look where it is now). In the grand scheme of things, use a library because you need it, not because "it's there".
@julesoscar8921
@julesoscar8921 5 ай бұрын
how can i pass arguments now ?
@icodethis
@icodethis 10 ай бұрын
goat
@VishnuHaridas
@VishnuHaridas 9 ай бұрын
I think Kotlin should come up with a DI framework *as a part of the standard library* or a kotlinx library like Coroutines.
@AlfredGuimaz
@AlfredGuimaz 10 ай бұрын
Don’t we need dagger for compose navigation?
@PhilippLackner
@PhilippLackner 10 ай бұрын
Why would you?
@deletedchanneI
@deletedchanneI 10 ай бұрын
this manual solution will work only on simple examples like in this video store VM-scoped modules in companion object of ViewModel? forget about simultaneous usage of VMs of this type
@gekylafas
@gekylafas 10 ай бұрын
So, providing the appContext to AppModuleImpl was not really necessary, was it? At least in those examples. Neither the -Api nor the -Repository classes need a Context. This is especially true for KMP projects where shared code shouldn't use Android-specific classes.
@olegleonov1310
@olegleonov1310 10 ай бұрын
Looks like service provider, but how you can create scopes for lifecycles for objects with your manual "di'?
@PhilippLackner
@PhilippLackner 10 ай бұрын
As I've mentioned in the video, you could initialize a module inside of your viewmodel for example for viewmodel scoped dependencies. For activities it's a bit trickier if the dependencies should survive config changes
@olegleonov1310
@olegleonov1310 10 ай бұрын
@@PhilippLackner I mean how we can create an object which can not be collected by GC only on two screens, for example. We have scopes in Dagger for that purpose, but how can you do it manually?
@PhilippLackner
@PhilippLackner 10 ай бұрын
If you need this, better use Dagger haha. You'd need to tie the creation of the module to the back stack entry (in that case of a nav sub graph) and set it to null when the back stack entry is destroyed
@olegleonov1310
@olegleonov1310 10 ай бұрын
@@PhilippLackner 🙂
@Adam0001
@Adam0001 10 ай бұрын
👏
@RishiRajxtrim
@RishiRajxtrim 10 ай бұрын
🎉
@Scotthutchinsonking
@Scotthutchinsonking 4 күн бұрын
I thought the whole time I was crazy for thinking dagger was overcomplicated coming from a .NET where injection is baked in
@ozzy4654
@ozzy4654 4 ай бұрын
Thats why i perfer KOIN its a great balance and simpler approach than dagger
@mukulpathak9389
@mukulpathak9389 10 ай бұрын
Whole idea is to use Dagger or DI framework is to develop faster and build scalable solution also you wont know when your business gets complicated and your so called lagecy code becomes a problem to maintain. Phillip just want us to understand the DI concept but he is not discouraging you to use dagger or hilt. I would say if your build time is bothering you try to use service locator based DI framework (Koin) instead annotation processor based Dagger. Both have pros and cons but dont go with manual dependency injection for production code
@ChrisAthanas
@ChrisAthanas 10 ай бұрын
On point
@ChrisAthanas
@ChrisAthanas 10 ай бұрын
I would add this is fine for apps up until around 30,000 lines At that point you will likely need a solution like hilt or koin
@mikeshilovski1512
@mikeshilovski1512 10 ай бұрын
Koin for the win
@theman3282
@theman3282 10 ай бұрын
mean while MAUI or xamarin is way leap ahead and this kind thing is just standard
@DJOrangeJoe
@DJOrangeJoe 10 ай бұрын
But MAUI xaml UI + viewmodel is a pain in the ass compared to jetpack compose :D
@theman3282
@theman3282 10 ай бұрын
@@DJOrangeJoe lol no..superb intellisense and you can code them in c# as well and biggest of all no gradle bullshit incompatible bla..bla.., plus are you not catching why DI is important and why dagger is needed back then, lol?
@John-qt6qk
@John-qt6qk 10 ай бұрын
😱😱
@ano9161
@ano9161 10 ай бұрын
It's Wednesday again!
@Dibyendu.M
@Dibyendu.M 10 ай бұрын
Hey Philipp, make a project on jetpack media3. Please, consider this.
@OlegGolubev_yolo
@OlegGolubev_yolo 7 ай бұрын
so we reinvent the wheels? Ain't that was an ordinary stuff before dependency injection were introduced? I definitelly can't call this a simplier solution, unless we work on a very simple application itself
@PhilippLackner
@PhilippLackner 7 ай бұрын
Technically speaking, dagger was the reinvention of the wheel
@OlegGolubev_yolo
@OlegGolubev_yolo 7 ай бұрын
yeah, just was scarried a little bit that we going wrong way :P @@PhilippLackner
@azizulhakim1380
@azizulhakim1380 10 ай бұрын
is Dagger or Hilt free?
@ChrisAthanas
@ChrisAthanas 10 ай бұрын
Yes it’s free Just very steep learning curve and difficult to work with
@youdube1203
@youdube1203 10 ай бұрын
Manual DI?
@Dimkar3000
@Dimkar3000 5 ай бұрын
What this video boils down to is that DI is a pattern, not a library. Hilt is an implementation and there are other. You can also write your own. My question is: If your app is so simple that you can write your own DI solution, then maybe you don't need it at all. Just lazyinit what you need in the application class and be done with it.
@josebraz5856
@josebraz5856 8 ай бұрын
Koin is better for small or kmp projects than manual DI
@vladimirvyukov6676
@vladimirvyukov6676 10 ай бұрын
Thank you very much! But, how do you know, what I need right now? 😊
@arjun1194
@arjun1194 7 ай бұрын
This is service locator not dependency injection
@louigienarvaez3019
@louigienarvaez3019 10 ай бұрын
I don't recommend using manual DI. It can become cumbersome and error-prone as your project grows in complexity. This is not recommended for larger projects or projects where maintainability and testability are more important than build time and gradle errors.
@deviantstudio
@deviantstudio 10 ай бұрын
Koin ☝
@Zhuinden
@Zhuinden 8 ай бұрын
You should not be passing the AppModule itself to the ViewModel, even with manual DI. Other than that, great video.
@BeyondOneSoul
@BeyondOneSoul 10 ай бұрын
So, you just made a service locator. Which we already have a solid solution, Koin. Even in a "small" project it's not worth to implement a manual service locator as the simplest project will scale at some point. And then you have to struggle between adapting the architecture for the new set of features or refactors and migrating your service locator to another more solid solution... Reinventing the wheel in this area is not worth it in my opinion.
@dreewr
@dreewr 10 ай бұрын
Koin is very error prone in large production apps...
@dreewr
@dreewr 10 ай бұрын
One line of code removed in a merge and your app goes to production with a crash - happened with me after QA tests, automated tests etc etc
@BeyondOneSoul
@BeyondOneSoul 10 ай бұрын
So you are telling me that a line removed in a project with QA tests, automated tests, unit tests (I'm assuming), PR reviewers and yourself testing the feature or change is going live like nothing and it's a Koin / Service locator problem? You should rethink or talk with your peeps about the current state of your project... It looks like there is space for improvement there.@@dreewr
@BeyondOneSoul
@BeyondOneSoul 10 ай бұрын
And let me tell you by my experience that you are wrong. I'm currently working in a very large bank app with multi country support and modular presentation layers (different UIs per countries) and Koin works awesome@@dreewr
@ChrisAthanas
@ChrisAthanas 10 ай бұрын
No, these dependencies are all defined at compile time Service locators resolve at run time, which can easily cause problems in production
@DJOrangeJoe
@DJOrangeJoe 10 ай бұрын
I prefer koin over dagger. Dagger seems massively overcomplicated to me.
@akashsinha5148
@akashsinha5148 10 ай бұрын
Finally someone saved us from dagger's sharpness
@ShaqarudenGames
@ShaqarudenGames 10 ай бұрын
There’s koin
@mateusznepath3344
@mateusznepath3344 10 ай бұрын
Thank you for the video. But please... 9:56 do no leave warnings in your video code. People need to know that they should not leave warnings. I really hate it when i get into someones code and all i see i yellow color
@user-qc2yb7ki9y
@user-qc2yb7ki9y 9 ай бұрын
Okay, thank you, but I will still use Dagger😂😂
@houssemzaier
@houssemzaier 10 ай бұрын
I totally disagree, I'm working on real world apps that have millions of users and more than 20 Android developers Using Hilt in Android development offers several advantages such as simplified configuration, reduced boilerplate code, and ease of maintenance. It automatically handles the complexities associated with component lifecycles, allowing for more streamlined and readable code. Hilt also provides compile-time validation, which makes it easier to catch errors early in the development process. By using annotations, it makes dependency injection more declarative and easier to understand, improving code readability and reducing the likelihood of mistakes. On the other hand, manual dependency injection, while offering more control, can become increasingly complex and error-prone as your project grows. Manually managing component lifecycles and dependencies can lead to a fragmented and less maintainable codebase. Additionally, the lack of compile-time validation in manual dependency injection means errors may only become apparent at runtime, making debugging more challenging.
@PhilippLackner
@PhilippLackner 10 ай бұрын
Then you got wrong what I wanted to show with this video, see my pinned comment :)
@houssemzaier
@houssemzaier 10 ай бұрын
In the video, you mentioned that you're unsure why dependency injection in Android is complicated, suggesting that perhaps Dagger Hilt solves a "mysterious problem." The complexity arises from Hilt's capability to manage dependencies using a Directed Acyclic Graph (DAG) that also takes care of the lifecycle management of the components your class relies on. This becomes increasingly challenging to handle manually in larger apps, and mistakes can lead to runtime errors. While it's true that for smaller, tutorial-level apps, you might be able to sidestep these issues, they become critical in real-world applications. These complexities not only pose a risk in terms of application stability but also contribute to productivity issues and technical debts, especially when new developers join the team. All these challenges can pose significant risks for a company.
@skullkrum20
@skullkrum20 10 ай бұрын
This is a lot of words to say effectively nothing.. I’m sorry but it’s true. You’re just repeating over and over how it makes the code mor maintainable, scalable but you never mention why you think that? Also I am not sure what compile time safety you think you get with dagger hilt that you don’t get with manual DI? You have all the safety with manual DI. Your app will not compile if you don’t provide all dependencies since you’re the one calling the constructors. Dagger / hilt is easier to understand and maintain then plain Kotlin code? I’m sorry but if you don’t understand Kotlin code then how will you understand any other part of your code base?
@houssemzaier
@houssemzaier 10 ай бұрын
@@skullkrum20 I'm so sorry for you if you didn't understand the meaning, and sorry it's really obvious what does it mean scalability and maintanabilty when you have experience. When you write less code you get less errors so better maintenance.
@houssemzaier
@houssemzaier 10 ай бұрын
@@skullkrum20 with manual DI you are never safe. And especially when you have a lot of contains in the app, while you are trying to resolve memory problems related to the lifecycle of your app
@marta_na_moto
@marta_na_moto 10 ай бұрын
I hate dagger with a passion but reinventing the wheel is not the way.. however k..k..koin ? ;))
@dreewr
@dreewr 10 ай бұрын
It's not reinventing the wheel, it's the wheel itself. The pattern is agnostic of the tools that implement it.
@ChrisAthanas
@ChrisAthanas 10 ай бұрын
@@dreewragree This is what the DI is doing under the hood anyway Dagger/Hilt is an overcomplicated mess and often causes more problems than it solves and the documentation is TERRIBLE Thermosiphon this! Lol
@mackomako
@mackomako 10 ай бұрын
Thanks for showing us how DI works. But why bother to write all this boiler plate code? Hilt is stupidly easy to set up and use. Build time is not an issue for small projects. For bigger projects, you can go multimodule to slash down build times to almost nothing. I would not go with manual DI setup for any production app. And small comparison between Koin vs Dagger2/Hilt: during runtime Dagger2/Hilt has only ~third of memory footprint of Koin. Everything has pros and cons. Choose wisely :)
@Dibyendu.M
@Dibyendu.M 10 ай бұрын
I feel like Hilt is easier than this. 😅
@ChrisAthanas
@ChrisAthanas 10 ай бұрын
Only because you have trudged up the mountain and are confiable with its methodology Can you remember your first encounter with hilt/dagger and how it felt This approach is a better step before full blown hilt implementation
@Dibyendu.M
@Dibyendu.M 10 ай бұрын
@@ChrisAthanas Indeed, it was not easy for me until I implemented this in my projects.
@ChrisAthanas
@ChrisAthanas 10 ай бұрын
@@Dibyendu.M exactly The technique given here is a very useful in-between step Shows the reason why a DI library is necessary but only after you fully understand it Deploying the solution with Kotlin is a great way to introduce the DI concept, because it's very clear what's going on, so adding a DI library will be much less confusing
@GTechYoutube
@GTechYoutube 9 ай бұрын
I don't understand why this much work for simple work, just use objects that will solve most of your singleton problems
@argahutama
@argahutama 10 ай бұрын
I disagree with this, especially when you're working with big Android team.
@pyaesonehan19
@pyaesonehan19 Ай бұрын
@omaryousifkamal4290
@omaryousifkamal4290 10 ай бұрын
goat
Learn React In 30 Minutes
27:16
Web Dev Simplified
Рет қаралды 1,3 МЛН
WorkManager - Android Basics 2023
34:22
Philipp Lackner
Рет қаралды 49 М.
Каха ограбил банк
01:00
К-Media
Рет қаралды 10 МЛН
Alat Seru Penolong untuk Mimpi Indah Bayi!
00:31
Let's GLOW! Indonesian
Рет қаралды 8 МЛН
OMG😳 #tiktok #shorts #potapova_blog
00:58
Potapova_blog
Рет қаралды 3,7 МЛН
Smart Sigma Kid #funny #sigma #comedy
00:19
CRAZY GREAPA
Рет қаралды 23 МЛН
3 Clean Code Hacks I Bet You Didn't Know (Kotlin & Android)
12:30
Philipp Lackner
Рет қаралды 25 М.
I Discovered a Better Approach to NestJS Configuration
3:41
Android Dependency Injection - Manually Injecting Dependencies
14:54
Simplified Coding
Рет қаралды 15 М.
The Top 3 State Management Mistakes On Android
14:30
Philipp Lackner
Рет қаралды 21 М.
Hilt and dependency injection - MAD Skills
13:06
Android Developers
Рет қаралды 46 М.
Make Your Code Clean With the SOLID Principles
18:24
Philipp Lackner
Рет қаралды 95 М.
Каха ограбил банк
01:00
К-Media
Рет қаралды 10 МЛН