Service is concrete and should be abstract (Interface) for this example to be 100% loosely coupled. The whole idea DI is to have a loosely coupled design.
your sound looks very good ,and so clear, the way you explained/described the idea in developing it was also nice,but you missed the full definition of the term at the first place ,you should be saying ,dependencies are ....,then you go to dig into the subject.thanks anyway.
8:20 You don't actually need Service object in the Customer class. In fact, Your class is still somewhat dependent on the Service class since the constructor expects it as an argument to instantiate the Customer. A better approach would be to directly pass the service object as an argument to the method, e.g. viewCustService(Service s), and use it inside the method. This way, your class is not dependent on it, and solely viewCustService will expect it as an argument not your class. So even if there is a problem with the Service class, your Customer class will still instantiate perfectly but you may encounter an issue only when the viewCustService is called.
Love the page. Forgive me if I mistake you and I mean nothing by it but you sound like a black man and I love supporting and linking up with all coders but especially black coders ✊🏿✊🏾✊🏽✌🏾🙌🏾👍🏾 Followed, I'll spread your videos!
Nice and simple explanation of DI. However a few remarks in terms of java best practices: "name" field should be defined "private" in Service class (encapsulation), and there is no use to return string from viewCustService method in your example (redundant) since you already print the service name inside the method. I believe explanation of complex issues should still follow the best/basic practices. Regards.
Hi, this is the same as we call association right? When we have instance of some object in a class. For i.g. public Class Wheel { .... } public class Car { private Wheel wheel; } Is this the same as DI how you explain? I am learning Spring boot and there are many confusing things that that i learn in Java SE and EE (servlets, JSP,...)
Dependency Injection Lay Man Terms. A charging adapter with usb port has inverse dependency with pendrive. Direct dependency means only a pendrive can be plugged into the charging adapter. Usb (universal serial bus technology is called the interface) . The company that made the adapter exposed an interface. Pendrive making company injected the dependency which is the pendrive device. Since the charging adapter has reversed or inversed the dependency you can now plugin a mouse or a keyboard or anything to this adapter. Thats it
I thought the reason for dependency injection was to allow us to change the dependency outside of the class. So as to promote decoupling. And you would use an interface to do this.
I didn't get it. First you used initializer statement to set the customer instance member. So each time you instanciate the class, you create a Service instance with the "coolservice" string. For each Customer instance you create a new Service instance with a similar string (or maybe same according to Java compiler optimization of strings litterals). This is different than using a static member initializer where each instance would share a single Service instance. Next, you move the Service instanciation out of the Customer class but you pass it to the constructor. In effect, its customer member is initialized with the external instance. So, in the end, the Customer class still references internally a Service instance as an instance member. I don't get how it is less coupled than at the beginning of your explanation. Could you elaborate more about that?
Yes, however you're not initializing the dependency in that class. Rather you're passing it to a parameter in the constructor so you can set it outside of the scope of that object.
good content. but I cant trust anyone with a light IDE theme. either you only work 10 minutes a day, or your retinas are completely burnt out at this point
I find the dark theme really annoying and I feel that my eyes are more strained when I use it. And for the past 1 year I have been working 8 hours every day so there are exceptions I guess :D
Service is concrete and should be abstract (Interface) for this example to be 100% loosely coupled. The whole idea DI is to have a loosely coupled design.
Thanks for the example. Great, comprehensible explanation.
Very well done, not too simple, and not overly complex in the explanation.
This was the easiest and clearest video illustrating this concept, thanq
very good stuff. much more understanding of this concept. Heard it tossed around alot and great :)
Amazing explanation. Very clear and I finally understand it. Your video is better than the other ones I've watched.
Simple and sweet Explanation
Thank You !!!
your sound looks very good ,and so clear, the way you explained/described the idea in developing it was also nice,but you missed the full definition of the term at the first place ,you should be saying ,dependencies are ....,then you go to dig into the subject.thanks anyway.
Very good explanation...clear and understandable
Clear and simple Explanation..thanks
simple explanation... thank you so much!
Simply Awesome!! Thanks! :)
Thanks
Finally I understood what is dependency injection
excellent way to explain dependency injection thank you
Thank you for this!
Great video
Thank you for this video.
Nice Explanation.
Far from mediocre, this video is cool.
Great work Thank you
Thanks, so simple, so helpfull
8:20 You don't actually need Service object in the Customer class. In fact, Your class is still somewhat dependent on the Service class since the constructor expects it as an argument to instantiate the Customer. A better approach would be to directly pass the service object as an argument to the method, e.g. viewCustService(Service s), and use it inside the method. This way, your class is not dependent on it, and solely viewCustService will expect it as an argument not your class. So even if there is a problem with the Service class, your Customer class will still instantiate perfectly but you may encounter an issue only when the viewCustService is called.
'Pretty much' on the ball. Thank You
Good video. Thanks
Awesome explanation!
Love the page. Forgive me if I mistake you and I mean nothing by it but you sound like a black man and I love supporting and linking up with all coders but especially black coders ✊🏿✊🏾✊🏽✌🏾🙌🏾👍🏾
Followed, I'll spread your videos!
Great tutorial bro!
Great explanation :)
Nice to see the FL Studio logo :)
Great! Thanks! Short and VERY helpfull !
btw you sound little like Samuel L. Jackson :D
haha
thank you for the video, it was helpful!
Nice and simple explanation of DI. However a few remarks in terms of java best practices: "name" field should be defined "private" in Service class (encapsulation), and there is no use to return string from viewCustService method in your example (redundant) since you already print the service name inside the method. I believe explanation of complex issues should still follow the best/basic practices. Regards.
Hi,
this is the same as we call association right? When we have instance of some object in a class. For i.g.
public Class Wheel {
....
}
public class Car {
private Wheel wheel;
}
Is this the same as DI how you explain?
I am learning Spring boot and there are many confusing things that that i learn in Java SE and EE (servlets, JSP,...)
Finally doubt got cleared. Thanks
iknr the name is so big and the concept is so small doubt just keeps creeping in on what it is even after three years
Thank you for explanation. It is easy to understand.
This is the best video about DI, I have ever seen!!! Thank u, u explain this very,very good!
So basically instead of hardcoding object creation in classes you pass it to constructor as argument?
Thank you. I've had so much trouble with this concept. I believe I understand it now.
Thanks man.
Dependency Injection Lay Man Terms. A charging adapter with usb port has inverse dependency with pendrive. Direct dependency means only a pendrive can be plugged into the charging adapter. Usb (universal serial bus technology is called the interface) . The company that made the adapter exposed an interface. Pendrive making company injected the dependency which is the pendrive device. Since the charging adapter has reversed or inversed the dependency you can now plugin a mouse or a keyboard or anything to this adapter. Thats it
So in nutshell, it's passing an obj1 as a constructor argument to obj2, where object1 is an object's field of obj2.
thank you
I thought the reason for dependency injection was to allow us to change the dependency outside of the class. So as to promote decoupling. And you would use an interface to do this.
Thanks
I didn't get it. First you used initializer statement to set the customer instance member. So each time you instanciate the class, you create a Service instance with the "coolservice" string. For each Customer instance you create a new Service instance with a similar string (or maybe same according to Java compiler optimization of strings litterals). This is different than using a static member initializer where each instance would share a single Service instance.
Next, you move the Service instanciation out of the Customer class but you pass it to the constructor. In effect, its customer member is initialized with the external instance. So, in the end, the Customer class still references internally a Service instance as an instance member.
I don't get how it is less coupled than at the beginning of your explanation. Could you elaborate more about that?
thanks
thank u
Great! Thanks!
cool service
You still have an instance of Service in the Customer class as a member... isn't that still a dependency?
Yes, however you're not initializing the dependency in that class. Rather you're passing it to a parameter in the constructor so you can set it outside of the scope of that object.
So basically this is Aggregation ¿
"mmmkay?"
How is this a “feature” of frameworks? This is simple OOP..
He is explaining the DI concept in OOP.
Name sounds daunting but it really is an easy topic if you look closely.
fei fei sun
Please zoom in
good content. but I cant trust anyone with a light IDE theme. either you only work 10 minutes a day, or your retinas are completely burnt out at this point
I find the dark theme really annoying and I feel that my eyes are more strained when I use it.
And for the past 1 year I have been working 8 hours every day so there are exceptions I guess :D
Nick Fury teaches OOP on RUclips?
Not for 101 students
I don't think 101 students are his target audience, since these are interview questions.
Fair point
wow, eclipse looks so poor in comparison to visual studio :)
Worst
7 mins into the video and I still dont know what dependency injection is 👎👎👎