Dependency Injection in a Nutshell

Поделиться
HTML-код
  • Опубликовано: 25 ноя 2024

Комментарии • 134

  • @sbrugby1
    @sbrugby1 3 года назад +123

    So anytime I've made a class with a constructor that takes arguments I've just done dependency injection? That's essentially what I got from this.

    • @stati5tik
      @stati5tik 2 месяца назад

      Yes, in a way. If you pass instances to that that class another class manages the instanciation of that particular class and by that the lifetime of that object. The dependency is therefore injected.
      And God alone knows best.

    • @cameronmcnz
      @cameronmcnz 2 месяца назад +3

      Yes, and that would be 100% incorrect. They didn't invent the term DI to describe passing arguments to a constructor. We were doing that 20 years before the term DI was invented. The presenter seems to actually have no idea what DI is.

    • @cameronmcnz
      @cameronmcnz 2 месяца назад +3

      @@stati5tik No, not in any way. Do you really think they invented the term DI to describe passing arguments to a method? No. No they didn't. This video describes how to use a parameterized constructor, something you learn after coding Hello World. But this has nothing to do with dependency injection.

    • @stati5tik
      @stati5tik 2 месяца назад

      @@cameronmcnz yes, it is - in a way - dependency injection. It seems as if u dont know what the basic principle of that is: inversion of control. When you have a class A that is dependent on references passed through constructor, the very class I that instanciates A acts as a DI container managing the lifetime of the said object's which references it passes further to A.
      The basic principle is: if A does not create all the object's it needs the dependency must be injected externally.

    • @cameronmcnz
      @cameronmcnz 2 месяца назад

      @@stati5tik What's with this 'in a way' vagueness? Either it is or it isn't, and calling a parameterized constructor most definitely is not. Do you actually think the term DI was invented to describe calling a parameterized constructor or passing a value into a setter? Because if you do, then you have no idea what DI is, which seems rather clear from the video. You're suggesting that every time one class calls the constructor of another class that it's DI, and that simply is not the case. It demonstrates a fundamental misunderstanding of both DI and IoC.

  • @colin398
    @colin398 Год назад +5

    Java programmers discover function arguments

  • @alroygama6166
    @alroygama6166 3 года назад +118

    People make playlists with 20+ vids and still can't explain why we use it in the 1st place. And you explained it so precisely in just 2 min. Fuckin legend.

  • @codinginflow
    @codinginflow 3 года назад +86

    Thank you sir finally I can understand the dependency injection

  • @VincentNeemie
    @VincentNeemie 10 месяцев назад +3

    Those videos are so good, people underappreciate how good for problem solving a solution is when hard problems get a simple high level insight, especially if you also give them illustrations. Well done!

  • @MaisUmSomente
    @MaisUmSomente 2 года назад +1

    This boy has the gift of explaining, I had already understood what dependency injection is, but with just 2 minutes, everyone can understand this concept. THANKS👍

  • @amitray769
    @amitray769 3 года назад +1

    Thank you sir...Today after 1.5 years in Android I was able to understand dependency injection. I feared from this word.

  • @overtured
    @overtured Год назад +1

    That's a such a good video to start understanding the concept. Congrats!

  • @dcascato
    @dcascato 3 года назад +2

    Dear lord! Just perfect work with this video!

  • @newbiegameplayy
    @newbiegameplayy 3 года назад +7

    Please make tutorial for hit multiple api with different model using retrofit and coroutine 🙏🏻

  • @aishwaryakasthala97
    @aishwaryakasthala97 10 месяцев назад

    Wow. This is a great video with the simplest explanation. Thank you so much for this.

  • @MrVelyx
    @MrVelyx 8 месяцев назад

    Just the reminder i needed. Thank you

  • @evil_onyxx_jr.
    @evil_onyxx_jr. 3 года назад +2

    Hi Phillip. Thanks alot for this short and very explanatory video. I found dependency injection quite confusing but after watching this I have a good idea what it means and why it is useful. Thanks again Sensei 😊

  • @HaticeNisaBozkus
    @HaticeNisaBozkus Месяц назад

    That's why I love software development. I don't speak English, but I understood what was said.

  • @iJuce
    @iJuce 3 года назад +3

    Hey man can you make a video on how to properly read the android documentation? There are very few videos on youtube and how to do so and most of the aren't really helpful at all! Here is an idea: Just show how YOU read the documentation and what you do if you dont understand any topics.

  • @AmeenAltajer
    @AmeenAltajer 7 месяцев назад +1

    You're awesome man, great content!

  • @spidey5324
    @spidey5324 2 года назад

    Thanks! I finally understand what is dependency injection!

  • @matt-g-recovers
    @matt-g-recovers Год назад

    Yes well 2 minutes explaining what it is, and a couple 30 min videos describing a couple of premade solutions but what about a full course on it?
    Dependency management is one of the most difficult aspects of large scale enterprise level application development and doing DI correctly is far from easy...the concept of how is simple at the core but understanding when and what, then keeping it manageable and teatable across dozens of modules can be a huge undertaking.
    I would love to see a video about dependency injection the conceptual and theoretical rather than a specific tool

  • @koutheirelbehi4384
    @koutheirelbehi4384 3 года назад

    Philipp I have been following on Instagram and I must say I admire the fact that you keep the android community updated! I would love to see you present a sample project containing the latest architecture of android in 2021

    • @PhilippLackner
      @PhilippLackner  3 года назад

      Thanks! The latest architecture is still MVVM and I have a lot about that :D

  • @prateekmishra6245
    @prateekmishra6245 Год назад

    This was easy peasy here. Thanks

  • @BikersHub299
    @BikersHub299 Год назад

    Thank You ! You just earned a new subscriber 😇

  • @khlorghaal
    @khlorghaal 2 года назад +1

    i recommend applying this to one of your projects, to witness the hellscape you've become immersed in

  • @HaoWang-zp4vt
    @HaoWang-zp4vt 9 месяцев назад +2

    "Giving an object its instance variables", I wish I had seen this nice and simple explanation earlier, before I had to go through all the overworded definitions online that confused the sh*t out of me

    • @cameronmcnz
      @cameronmcnz 2 месяца назад

      Just so you know, giving an object instance variables is NOT dependency injection. The leaders of the industry didn't invent the term DI to describe a basic feature of every programming language that people learn after writing their first hello world. If initializing a variable is DI, then every setter you've ever called is DI, and every class you wrote that did so is an IoC container. Does that sound like a logical conclusion to you, or does such a ludicrous and unbounded conclusion not prove that the definition provided is fundamentally wrong?

    • @Zipperheaddttl
      @Zipperheaddttl 2 месяца назад +1

      @cameronmcnz I've seen you say this a bunch in these comments now. Yet you never explain what you the DI actually is.
      And do I think that programmers would invent a overly complicated word for an old and simple concept that people have been doing forever? Yes of course I do.

    • @cameronmcnz
      @cameronmcnz 2 месяца назад

      @@Zipperheaddttl You really think that leaders of the industry wasted their time just to come up with a new term to describe something as basic as 'calling a setter' or 'calling a non-default constructor.' Or do you think they were trying to describe an arising new pattern that didn't have a name yet? Seriously, just apply Occam's razor. The term doesn't describe calling a setter!
      The term's origin and what it describes is all explained in Martin Folwer's blog describing the specific situation in which an object retrieved by an IoC container has properties unobtrusively initialized by the framework. It's a pattern that provided loose coupling in a manner that contrasts against a service locator, which is exactly what Fowler does in his blog explaining it.
      The problem is that junior programmers don't understand terms like 'service locator' or 'IoC' and think "oh, he must mean calling a constructor!" If you go and read his article, you will see that never in the article does Fowler ever suggest that DI is simply calling a setter method or initializing a variable outside of a class. To suggest such a thing demonstrates a complete and total lack of understanding of IoC, DI and basic, fundamental OOA&D programming concepts.

    • @cameronmcnz
      @cameronmcnz 2 месяца назад

      @@Zipperheaddttl Just use some common sense.
      Do you think leaders of the industry got together and struggled to come up with a new term to describe 'initializing a variable' or 'calling a setter?' Or does it make more sense that the term was invented to describe a new and emerging development pattern that didn't have a proper name?
      Martin Fowler, who invented the term, was a signer of the Agile Manifesto for goodness sakes. He's not sitting around thinking 'we need a new term to describe variable initialization!'
      If you read Martin Fowlers blog about the word's origin and the word's meaning, you will see the term describes the *specific* pattern in which an object retrieved from an IoC container has its property unobstrusively initialzed by the underlying framework. A pattern that stood in stark contrast at the time to the service locator pattern.
      Here's the problem. Novice programers don't understand advanced terms like DI or IoC or 'Service Locator' and so they put out videos saying "oh, DI is just calling a setter! It's just calling a non-default constructor!"
      Pardon? How could anyone read Martin Fowler's blog and conclude DI is simply initializing an instance variable outside of a class? Initializing an object outside a class is a basic part of OOA/D. OOA/D wouldn't exist without it. It's something you learn right after 'Hello World'.
      Trust me, parameterizing a constructor is not DI. Anyone who suggests it is simply doesn't understand the concept.

    • @cameronmcnz
      @cameronmcnz 2 месяца назад

      ​@@Zipperheaddttl The term was coined by Martin Fowler to describe the new and novel way IoC containers were resolving the dependencies of the objects they managed without imposing on the business logic the same way a service locator would.
      That's what Di is. Problem is, to understand it, people need to understand ideas like IoC, containers and the service locator problem. Since those topics are beyond the junior developers who record these videos, they just say "DI is calling a setter!"
      I assure you, calling a setter or a non-default constructor is not DI. That's a basic programming concept that predates the term DI by 20 years.

  • @trocchiettoski
    @trocchiettoski 3 года назад

    Fantastic video, Pity this video was not around in 2014 when dagger thing came out

  • @beerensaft413
    @beerensaft413 Год назад +1

    dont understand who will do that @0:58 ?

  • @Confusedcapybara8772
    @Confusedcapybara8772 5 месяцев назад

    This was a great video! Thank you

  • @alexeymurnikov1413
    @alexeymurnikov1413 3 года назад

    The Best! As usual!

  • @NithinMWarrier
    @NithinMWarrier 3 года назад

    Very neatly explained, Thanks Philip

  • @BrunoGomes-su1bk
    @BrunoGomes-su1bk 2 года назад

    thaaankkss man, what a great explanation

  • @h.r.60
    @h.r.60 3 года назад

    Simply the best. Keep up the great tutorials 👍

  • @sebastiansopala6295
    @sebastiansopala6295 2 года назад

    Hi Phillip, I'm becoming your fan - love the way u explain things. Thanks!!

  • @tradingwithazoak
    @tradingwithazoak Год назад

    I have watched alot of videos, definitely longer than this, but I failed to get them, until I came here

  • @Sc2MooDy
    @Sc2MooDy 3 года назад

    very good quality, thanks!

  • @DEVENDRA-r3p
    @DEVENDRA-r3p 5 месяцев назад

    too good explanation ❤❤

  • @MrDoge-yp8us
    @MrDoge-yp8us 3 года назад +1

    For the next video please put a lofi song on the background :)

  • @notfoundbrain7020
    @notfoundbrain7020 3 года назад

    You really help beginners like me♥️

  • @Chintanparmar
    @Chintanparmar 3 года назад

    Mission Passed
    Respect++

  • @hunnyt-tech2978
    @hunnyt-tech2978 3 года назад +1

    Always Super😀

  • @orangasli2943
    @orangasli2943 2 года назад

    This is like having a pointer to another class..
    in the Computer class..
    first we initialize the pointer with null values in the private field section
    And then in our public constructor we assign what ever value for that object the computer gets from outside computer class

  • @m.irtizakhursheed3040
    @m.irtizakhursheed3040 3 года назад

    Awsome explanation

  • @SeemaSingh-yt8qq
    @SeemaSingh-yt8qq 16 дней назад

    Damn I can't believe someone explained it this fast?

  • @mahdiporkar236
    @mahdiporkar236 Год назад

    nailed it.

  • @mageshmani9176
    @mageshmani9176 3 года назад

    nice explained!

  • @AtriTripathi
    @AtriTripathi 3 года назад

    Philipp, where can I get the outro music that you used in this video?
    It is so good!

  • @gregoryfenn1462
    @gregoryfenn1462 3 года назад +4

    Honestly I’m more confused now, how is providing arguments to a class constructor function all there is to DI? If it’s as simple as function parameters, why on Earth is DI even needed as a concept, when it’s so basic to programming? By that definition, a function f(x) has DI when you provide x, since you can think of f as a class with one method and one class property

    • @PhilippLackner
      @PhilippLackner  3 года назад

      Yep it's all about managing your dependencies and not initializing them all over the place

    • @cameronmcnz
      @cameronmcnz 2 месяца назад

      You are 100% correct. What is described here is not DI. The presenter doesn't understand the concept. Calling a non-default constructor is not dependency injection, and anyone who says it is fails to understand the concept.

  • @marcinbiaecki9731
    @marcinbiaecki9731 3 года назад

    Thanks! :)

  • @subhashpatil3504
    @subhashpatil3504 3 года назад

    Please make tutorial on jetpack compose

  • @gajendrapandeya5081
    @gajendrapandeya5081 3 года назад

    Never seen beautiful explanation like this
    You are truly awesome tutor

  • @imnithish
    @imnithish 3 года назад

    great bruh

  • @ChrisAthanas
    @ChrisAthanas 3 года назад +2

    This is a perfect explanation of a complex subject that *SOME FAMOUS* engineers seem to relish in overcomplicating.... *cough*thermosiphon*cough*

  • @Maya-xe6xp
    @Maya-xe6xp 7 месяцев назад

    Brilliant

  • @tahirdevlog2047
    @tahirdevlog2047 3 года назад

    that's gold

  • @shreyashchoudhary7413
    @shreyashchoudhary7413 3 года назад

    Epic!

  • @navjotsingh2457
    @navjotsingh2457 Месяц назад

    Ty

  • @GenjaOrigins
    @GenjaOrigins Год назад

    very nice

  • @ddam712
    @ddam712 Год назад

    background music is a bit loud

  • @fb767
    @fb767 3 года назад +1

    Bro this was the best explanation ever. How in the world did you think of this example?!

  • @rohitjakhar6672
    @rohitjakhar6672 3 года назад +9

    you'r going to change the boring teaching method into fully dopamine release content like watching a movie

  • @nomanzafarzafar7912
    @nomanzafarzafar7912 3 года назад

    Please create an android app using dagger.

  • @pms_code
    @pms_code 3 года назад

    500th Like ❤️👋🏼

  • @satyamurtidoddini8304
    @satyamurtidoddini8304 3 года назад

    Awesome

  • @WilliamGao-nz8rr
    @WilliamGao-nz8rr 8 месяцев назад

    music is too loud

  • @Aicchio
    @Aicchio 8 месяцев назад

    So is it similar to using an abstract class?

  • @agungprakasa7214
    @agungprakasa7214 3 года назад

    request tutorial content provider sir. Thanks you

  • @kishorramani007
    @kishorramani007 3 года назад

    Hi Phillip, from where you are learning this topics in details?

  • @orangasli2943
    @orangasli2943 2 года назад +1

    Bro you talk about
    Managing memory in Dependency Injection..
    Do we need to manage the memory (lifetime of that dependency objects we are using)?
    Because if we use java or kotlin do we need to still explicitly deallocate memory for unused object?
    if so how can we do that?

    • @z13579bugi
      @z13579bugi Год назад

      Java has a garbage collector so it is not needed

  • @infodose3690
    @infodose3690 4 месяца назад

    They think they are safe now :D

  • @frederikbrecht30
    @frederikbrecht30 3 года назад

    Great video! Simple and easy to understand. I have a video suggestion: Could you show us how to prepopulate a room database with the .createFromAsset or .createFromFile methods? It would be greatly appreciated! Grüße aus Deutschland!

  • @cagrylmaz9051
    @cagrylmaz9051 2 года назад

    ❤❤

  • @Aditprayogo18
    @Aditprayogo18 3 года назад

    song name ??

  • @Mohit-il9gx
    @Mohit-il9gx 3 года назад

    Can you tell how to reset android stuido basic but i cant a good video on youtube

  • @anasouardini
    @anasouardini Год назад +1

    This video made it worse for me, your definition is like "if you need something to be specific for each object that consumes it, then go ahead and make instance for each object".
    Which is the equivalent of "if you feel hungry, then go eat", or "just don't be stupid".
    The fact that this....."Strategy" even has a name, is very confusing to me.

  • @fernandohood5542
    @fernandohood5542 Месяц назад

    Does anyone know what they are saying?

  • @ohmegatech666
    @ohmegatech666 Год назад

    So "constructor injection" is just using a constructor... the way you normally do?

  • @gappergob6169
    @gappergob6169 3 года назад

    Nice! Could you make video about custom view and compound view. There's not much video about that on youtube. Thanks 😊

    • @PhilippLackner
      @PhilippLackner  3 года назад

      not yet. I plan on doing that when jetpack compose is out

  • @Venlorz
    @Venlorz 3 месяца назад

    0:44 YT links block the video

  • @sumitsuryawanshi9060
    @sumitsuryawanshi9060 3 года назад

    while(true) { println("You're my hero") }

  • @cameronmcnz
    @cameronmcnz 2 месяца назад

    Another video that thinks passing arguments to a constructor is dependency injection. What you described is the textbook definition of a constructor and why you parameterize one. But if you think DI is simply calling a parameterized constructor, then you don't know what DI is. I'd even go so far as to say teaching people that is somewhat irresponsible. They didn't invent the term DI to describe a basic programming concept like passing arguments to a method. 🤦‍♂

  • @bugra1994
    @bugra1994 3 года назад

    what a weird choice of music :)

  • @Kunal-jp8tn
    @Kunal-jp8tn 2 года назад

    Thank you sir finally I can understand the dependency injection.