Interfaces in C# - What they are, how to use them, and why they are so powerful.

  Рет қаралды 454,507

IAmTimCorey

IAmTimCorey

Күн бұрын

Пікірлер: 1 100
@mauricemakesmovies
@mauricemakesmovies 3 жыл бұрын
This channel is kind of like an interface. It even has the capital "I" at the start of the name.
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
An interface for what, though?
@mauricemakesmovies
@mauricemakesmovies 3 жыл бұрын
@@IAmTimCorey Any project can inherit from your teachings. ;)
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
I like it.
@HDEditzz
@HDEditzz 3 жыл бұрын
@@mauricemakesmovies not to nitpick right now, but wouldn‘t you implement it, rather than inherit? ;)
@MaamuBhanjiVines
@MaamuBhanjiVines 2 жыл бұрын
@@HDEditzz spot on
@joeman123964
@joeman123964 9 ай бұрын
finally, a video where the content creator actually DEMONSTRATES the power of interfaces, not just creates one and then say like and subscribe.
@IAmTimCorey
@IAmTimCorey 9 ай бұрын
I’m glad you liked it.
@IMADETHISACCFORRAY
@IMADETHISACCFORRAY 5 жыл бұрын
God - I watched the entire session which Mosh did on interfaces on udemy and really couldn't grasp it at all. I then watch you, and you just make it so more intuitive and repeat things. It really clicked now. Thank you Tim, you are Godsent.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
I'm glad you found it so helpful.
@pitaszekfistaszek
@pitaszekfistaszek 3 жыл бұрын
Agreed. Mosh did completely non useful example with unit testing.
@vitaliysakun-duvalko8946
@vitaliysakun-duvalko8946 3 жыл бұрын
@@farfaraway2212 Nice that's really cool. Where?
@vitaliysakun-duvalko8946
@vitaliysakun-duvalko8946 3 жыл бұрын
Lol that's the same thing that happened to me. I still feel like he is a great instructor, and he helped me learn a lot in other areas.
@estebanlombardi
@estebanlombardi 4 жыл бұрын
After years of trying, this is my first time that I understood Interfaces ever. Thanks!!!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Excellent!
@lassel1644
@lassel1644 3 жыл бұрын
All good...caution pays👍
@dimasjimenez3396
@dimasjimenez3396 3 жыл бұрын
Same goes for me. Thanks a ton Tim!
@greentaco3402
@greentaco3402 Жыл бұрын
Watched multiple tutorials to try and understand what the practical point of interfaces was and none of them really explain why they're so useful. All of them explained what they are and will say they're super useful, but they never really explained why I would actually need to use them. This tutorial explained the why perfectly and now I get it, they are very useful. Thank you.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
I am glad it was helpful.
@sekki2554
@sekki2554 4 жыл бұрын
Man, your videos might be long, but we don't have to go through it thousand times to understand it. Thanks for your time.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You are welcome
@michaelkelly3241
@michaelkelly3241 4 жыл бұрын
I normally do not comment on videos, but... First, I must say the video explained all of the pressure points I have previously had with interfaces, even though if I am being honest I was only looking them up today because I was confused about one specific piece of implementation for a Space Engineers Script I am working on.... Second, this video is over 2 years old... It is still relevant and helping people... and most remarkably IAmTimCorey still seems to reply to basically every comment, no matter how trivial. This is amazing... You sir have earned my Thumbs Up, Subscription, and recommendation to others and I look forward to watching other videos you have to offer. Thank you again!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
I am glad it was helpful. Thank you for the kind words.
@aarondouglas3220
@aarondouglas3220 2 жыл бұрын
Almost 3 years later and this video is still teaching folks. I'm a developer who has fallen WAY behind in modern practices and you've been a wonderful teacher to bring me back up to date.
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Great!
@bulent2435
@bulent2435 2 жыл бұрын
true.
@johndinovo4168
@johndinovo4168 2 жыл бұрын
Tim, just want to say thanks. My first language was FORTRAN so you can infer my age. I've been programming C# since it first appeared, and I had seen Interfaces but never knew quite what to do with them,. You cleared all that up! I want to rewrite almost every piece of C# code I've ever written :) What always impresses me is the brilliance of the guys who came up with this stuff in the first place and put it into the language. In the great scheme of things there are the theoreticians, like them, who come up with a feature, the engineers like you who figure out how to use the features in powerful and efficient ways, and then the users like me who know a good idea when they steal it. Again, thanks!!!
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
You are most welcome.
@DamnTimCan
@DamnTimCan 3 жыл бұрын
7 years of coding C# and now I finally understand why interfaces. Thanks so much.
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 жыл бұрын
Thanks for looking to Tim
@jakezepeda1267
@jakezepeda1267 2 жыл бұрын
Thanks for this. So many videos explain what an interface is and how to use it, but not what problems it solves over basic inheritance and why you would want to use it other than because someone told you to. This was a great practical example :)
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Excellent! I'm glad you found it valuable.
@manamahalo1
@manamahalo1 2 жыл бұрын
This is my 3rd tutorials by Tim I have watched. I have to say he is the most amazing teacher I have ever had. I felt there was a big gap between C# fundamental to the actual .NET development. I went through 40+ tutorials and many were either too easy, scratched only the surface or too difficult; none ever explained so well. The more I watch the more I am convinced that I got to the right person. Cannot thank him enough!!
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
I am glad you have found my content so valuable.
@AudioJunkie79
@AudioJunkie79 4 жыл бұрын
This is probably the cleanest and easiest explanation of interfaces I have watched or read. Thank you very much for the video. This was super helpful. I come from the industrial automation world where these concepts are just starting to creep in for machine automation code development. This is super helpful.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You are most welcome. Thanks for watching.
@samadhistate9637
@samadhistate9637 3 жыл бұрын
Some people are just naturally good at teaching and explaining. It's a rare skill that not many have. TC is one such person. This is the second video I've watched in full and while I haven't needed to use Interfaces in C# much, I now have a much better appreciation of their use and why they're so powerful and useful. It's rare also to find a publisher who takes the time to answer questions in the comments often with a verbose answer, as opposed to less helpful short cryptic responses.
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 жыл бұрын
Thanks for growing your skills and sharing your insights with us.
@RalfsBalodis
@RalfsBalodis 4 жыл бұрын
0:00 - Intro 1:06 - Demo application walk through 4:50 - Explaining the problem: putting instances of different classes (product models) in one list (shopping cart) 7:54 - Creating an interface 12:53 - Implementing the interface 20:29 - List of type Interface 23:43 - Note about items in the List of type Interface: Accessing a Class member not in the contract (Interface) 25:07 - recap: basics of the Interface 26:48 - Class Inheritance and Interface implementation 29:02 - Extracting the Interface from a Class 31:19 - Interface implementing another Interface 34:54 - Accessing a Class member outside the initial contract (Interface) in the List of type Interface 40:51 - Power of Interfaces: Adding a new Class to your project, why to use Interfaces
@nicolasm1664
@nicolasm1664 4 жыл бұрын
Have my like sir
@RalfsBalodis
@RalfsBalodis 4 жыл бұрын
@@nicolasm1664 I hope this was helpful!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Thanks! I added it to the description.
@kramesh3821
@kramesh3821 10 ай бұрын
Hi Tim. I have been in engineering programming for two decades. I was brushing up some advanced C# topics with your videos. These are absolutely fantastic, very clearly explained taking into account all aspects. Your teaching method is by far the best. Thanks.
@Ahmedibrahim0100
@Ahmedibrahim0100 4 жыл бұрын
I think you know perfectly what a student needs. Great job, Tim.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Thank you!
@willemvdk4886
@willemvdk4886 Жыл бұрын
I love these video's Tim! I'm an experienced programmer with various different languages, C# was never one of them, but I'm trying to pick up C# to be able to help a colleague out. Most tutorials are way too basic and beginner-oriented. Your video's exactly hit the spot for me, teaching most of the real C# "gotcha's" instead of how logic operators and if-statements work.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
I'm glad they have been helpful.
@barrythompson3359
@barrythompson3359 4 жыл бұрын
Replies to comments **2 YEARS LATER** We need more people like him
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Thanks!
@KevinNguyen1
@KevinNguyen1 3 жыл бұрын
Definitely cleared things up. Before I watched this video, I thought interfaces were like header files in C++, but now after watching the video, they do something else than what I thought.
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
I’m glad it was illuminating.
@dylanbaird7987
@dylanbaird7987 3 жыл бұрын
I've been using interfaces in my code because that's what the code base was like, that's what the books told me to do, and I understood it as a "best practice". This video helped me understand why those three statements hold up. Thanks for that. Great video.
@karendoran3692
@karendoran3692 6 жыл бұрын
Tim, I have been struggling with interfaces for the last two months trying to understand how they were advantageous and why I would need them but after watching this video the light bulb went on and I finally see the light. Thank you for presenting this in a way that actually makes sense in a practical example!
@IAmTimCorey
@IAmTimCorey 6 жыл бұрын
Awesome! I'm glad things clicked and you were able to see the value in interfaces.
@ookennedy
@ookennedy Жыл бұрын
This is the clearest explanation of interface I have seen. Thank you
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome.
@stannisbarracuda5693
@stannisbarracuda5693 2 жыл бұрын
best video i have ever seen on interfaces ever and i've been coding for 3 years
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Thanks!
@T.N.T.15
@T.N.T.15 2 жыл бұрын
say did this cover adding the interface to a startup? i seemed to have missed that if it was added.
@owiz9212
@owiz9212 4 жыл бұрын
Tim, your explanation for Interfaces is the best I've seen. You really make a concept that seems rather complex quite simple. I appreciate the time and effort that you put into these videos.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
I am glad it was so helpful.
@maurices.3194
@maurices.3194 4 жыл бұрын
Have to agree! I never understood the concept of interfaces and abstract classes because it was too complex for me to understand and most explanations i found didn't bring over the message, only examples with animals or cars. Now I got it, thanks to your Videos. I also got a bit more into Async developoing. I appreciate your videos, they do really open a big new field for me.
@joshr3739
@joshr3739 4 жыл бұрын
Just wanted to say that I'm pretty new to c# having come from a Javascript functional programming perspective. This is by far the best video on interfaces I've seen, most videos just ended up confusing me even more but you're super clear and easy to understand. Thank you so much! Really appreciate the time you spent to help people understand :)
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Glad it helped!
@chakravarthye
@chakravarthye 4 жыл бұрын
You are a genius when it comes to teaching.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Wow, thank you!
@stevejohnny1111
@stevejohnny1111 2 жыл бұрын
"34:54 - Accessing a Class member outside the initial contract (Interface) in the List of type Interface" was soooo useful, thank you. Nobody has ever explained that to me before. So powerful!
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Great to hear!
@ajaykumark107
@ajaykumark107 2 жыл бұрын
Probably the best video on interfaces, I have seen on internet! Great job!!!
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Thank you!
@maiksonstrife
@maiksonstrife 2 жыл бұрын
That's the best explanation I've ever seen about Interfaces, it links different topics, and cover their different use while expanding its concepts with real-life use but yet simple to understand.
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Awesome! I am glad it was so helpful.
@madhavmehendale7324
@madhavmehendale7324 4 жыл бұрын
What a brilliant brilliant brilliant video! Every hour, every day I learn little more..... or, in the case of your videos "a whole lot more"!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Great to hear!
@ShayanFiroozi1
@ShayanFiroozi1 4 жыл бұрын
Every time i search something about C# , your channel would be on top !! you are a hero Tim.👍👍
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Glad you enjoy it!
@Sunstriderko
@Sunstriderko 3 жыл бұрын
Tim this video is GOLDEN. I cant find words which describe that amount of help this video provided to me.
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Awesome! I am glad my content has been so helpful.
@mkd1964
@mkd1964 4 жыл бұрын
This is THE BEST explanation of Interfaces I've come across. Thank you for the "real-world" example. Before seeing this, everyone's else's explanation just seemed like "another layer of stuff", as you put it. I just couldn't see the point. But this really made clear, how useful Interfarcs can be.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Glad it was helpful!
@VitaliyParitskiy
@VitaliyParitskiy 4 жыл бұрын
Slow, steady and well explained. You got me!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Glad to hear it
@rayl1244
@rayl1244 4 жыл бұрын
Went through this lesson a number of videos ago. What I appreciate most is the time Tim takes to explain pitfalls and benefits among other facets of using different parts of a structure, class or what have you. About 12 years ago I build an Interface app in C++ from the ground up. So now I know more of what I did was all about. But I don't think I miss all the background code that VS puts in, you don't even have to worry about the entry point. Although I program mostly as a hobby, I pretty much am self taught. Beginning with writing FORTRAN code on punch cards, a few years ago, and now learning C# and working with ADO during CV-19 quarantine these instructional videos have been, well, fun.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
I am glad you enjoyed them.
@anhtuanle8318
@anhtuanle8318 3 жыл бұрын
Tim Corey, you are one of the best programming teachers
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
I appreciate the kind words.
@AndrewErwin73
@AndrewErwin73 5 жыл бұрын
I have always found interfaces useful for enumeration...so, anything that implements the interface is essentially one of those "things". So, if I have ICar that is implemented by class Kia, class Ford, and class Chevy, I can still count all of the ICar objects. It is a great way to simulate multiple inheritance. The problem comes in interpreted languages like PHP! If you add a signature to an interface without telling the author of a class that implements it, the whole application breaks! At least in C# you figure that out at compile time. EDIT: I made this comment about 15 minutes in... I watched the rest and noticed that you basically explained some of those concepts as well. Great stuff, Tim. I have around 20 years of experience as a programmer, but I always catch great tips from your videos. At very least, I usually relearn something that I have forgotten about.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Glad you enjoyed it.
@Layarion
@Layarion 4 жыл бұрын
I enjoy watching his vids at 250% - 400% playback speed with "Video Speed Controller", really helps me pay attention when I can watch at a pace that doesn't let my mind wonder too much.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Sounds good.
@bruceb8140
@bruceb8140 4 жыл бұрын
wheere do you find 400% playback? I've been trying to do this forever
@Layarion
@Layarion 4 жыл бұрын
@@bruceb8140 it's a chrome extension chrome.google.com/webstore/detail/video-speed-controller/nffaoalbilbmmfgbnbgppjihopabppdk?hl=en
@edisonverdejunior2190
@edisonverdejunior2190 5 жыл бұрын
Hi Tim! I just wanna say thank you. I'm Brazilian and kind of English Learner at intermediate level and also a beginner in .Net (C#) and even though, I could understand clearly the lesson. Congratulations to the great didactic way to teach.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
I am glad I am so clear to you.
@cecilchampenois4998
@cecilchampenois4998 Жыл бұрын
Thank, Tim. I was not aware that I could control the pixels level. Thank you. It's all very clear now.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome.
@GLuiz1982
@GLuiz1982 2 жыл бұрын
You save my life Tim, thank you very much. You are a true educator. I managed to understand everything and I'm not even an English speaker.
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
You are most welcome.
@Dual12d
@Dual12d 4 жыл бұрын
You deserve much more views than that. This was the best explanation I have ever seen so far.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
I appreciate the kind words.
@antipodestudios1753
@antipodestudios1753 6 жыл бұрын
I love how thorough you are for beginners. Most Unity Devs, such as myself, never wrote in C# before, and tried to find exactly this, but others fly through it, with little explanation. Keep up the great videos! You earned yourself a new sub.
@jymmorton5612
@jymmorton5612 6 жыл бұрын
Understatement. Like those videos where you can see that they have needed classes in the Solution Explorer but never show you what's in them.
@IAmTimCorey
@IAmTimCorey 6 жыл бұрын
Thanks!
@gregdoucetteguardianangel645
@gregdoucetteguardianangel645 4 жыл бұрын
Your literally a freaking great teacher. Thank you so much your explanation is fantastic. Literally, I understood what they were but didn't realize how interfaces were useful. So I guess I really didn't understand interfaces properly only that it was a contract to derived classes that implemented it. Thank you and btw even though your video is almost 48 mins I swear to god it felt like a few mins. So fun to watch thank you again. I look forward to your other advanced tutorials. I love you!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Glad I could help!
@Marcel-so4mq
@Marcel-so4mq 3 жыл бұрын
haha, nice... love your account name:)
@HironXuma
@HironXuma 6 жыл бұрын
Yet the best teacher i've ever met.
@IAmTimCorey
@IAmTimCorey 6 жыл бұрын
I appreciate the kind words.
@xtian437
@xtian437 4 жыл бұрын
Great tutorial! I recently shifted to a career in software development using ASP.NET and I'm so happy that I came across this awesome channel. Guess I'll be busy for a while watching your other vids :) Auto subscribed!!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Awesome!
@goldenwoof
@goldenwoof 6 жыл бұрын
I've been a developer for years, but am fairly new to C#. One thing I just couldn't get the grasp of was interfaces, no matter how many videos I watched, or how many tutorials I read. Yours made it very clear and easy to understand. Thank you! I'm a new subscriber to your channel and am very much looking forward to checking out your other stuff.
@IAmTimCorey
@IAmTimCorey 6 жыл бұрын
I'm glad it was clear and helpful. Welcome to the channel.
@tommygilchrist7771
@tommygilchrist7771 3 жыл бұрын
Well explained and helped by a really good practical example, this is the first time I've understood why you would use Interfaces.
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Excellent!
@KevinBFG
@KevinBFG 4 жыл бұрын
I never understood the use of interfaces until now, what an impeccable explanation on the subject. It's truly appreciated Tim, thank you!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Awesome!
@bigdummyhead2162
@bigdummyhead2162 4 жыл бұрын
Thanks you made this way more helpful then the C# Docs
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You are welcome.
@freedom13245
@freedom13245 3 жыл бұрын
Hi Tim, I have started working as a C# developer and your videos are helping me a lot. Thank you so much for this! I will tell everyone I know about this channel ;) Hands down one of the best if not the best to learn coding on KZbin!
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Awesome! I'm glad my content has been so helpful.
@parko1965
@parko1965 5 жыл бұрын
My god, after watching this, it's just clicked...thanks Tim Corey.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Awesome!
@fakuadegbenga9870
@fakuadegbenga9870 3 жыл бұрын
Thank you Tim, after months of partial confusion, I can fully say I understand interfaces
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Awesome!
@ranjanadissanayaka5390
@ranjanadissanayaka5390 8 ай бұрын
Thanks Sir so much. It feels amazing to have detailed knowledge on those topics.
@IAmTimCorey
@IAmTimCorey 8 ай бұрын
You are welcome.
@MrBombsn
@MrBombsn 4 жыл бұрын
holy sh1t, finally i understand what interfaces are for!! Everyone tells how they work, how to create them but no one explains what for. Except Tim! Thank you!!!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
I am glad it finally clicked!
@xieulong
@xieulong 4 жыл бұрын
Thanks Tim. This was a very thorough explanation and example.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Glad it was helpful!
@andresndergaard1712
@andresndergaard1712 4 жыл бұрын
This is just straight up fantastic! Explanations, illustrations and examples are clear and concise. 10/10
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Thank you!
@rikwouters5043
@rikwouters5043 2 жыл бұрын
These videos of tim are just extremely good
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Thanks!
@michalcertik249
@michalcertik249 5 жыл бұрын
By far the most clear and useful demonstration. Many thanks.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
You are welcome.
@TwoManyTenors
@TwoManyTenors 3 жыл бұрын
Coming from a book learning C# for Unity, this was tremendously insightful and explained the topic in a way that made sense, even if the context was completely different. Thank you for your wonderful work, definitely subscribing to fill in gaps in other areas going forward!
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 жыл бұрын
Thank you for continuing your learning with Tim.
@moonmadness9278
@moonmadness9278 3 жыл бұрын
Such a good and clear explanation! I finally get it ;) AmTimCorey - Class IAmTimCorey - Interface
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 жыл бұрын
Thanks for watching
@bigchunk1
@bigchunk1 4 жыл бұрын
45:30 I think I have to listen to this on repeat because I think I have made this mistake already multiple times. You're making me a better developer Tim. I appreciate your work.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Awesome! Glad it helped.
@nrich4704
@nrich4704 5 жыл бұрын
Great. After years of attempted explorations I finally get it. Thx
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Excellent!
@s4p1d3rm4n
@s4p1d3rm4n 3 жыл бұрын
Your video make me see clearly what is interface is for how to use and how to implement it, I've google for clear explenation about interface and none of them is as clear as yours. Thanks again for making this video
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Glad it helped!
@rinzler9775
@rinzler9775 Жыл бұрын
A lot of people will jump to inheriting from a base class rather than use an interface, the more you inherit, the harder the code gets to maintain as a general rule..
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Correct.
@elliottparedes
@elliottparedes 2 жыл бұрын
Tim i've been puling my hair out not understanding why we have to have this extra step of making an interfaces in C# but now the lightbulb went off and i get it. Thank you SO much
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Awesome!
@gregoWahoo
@gregoWahoo 2 жыл бұрын
OMG Somebody that explains tech as well as Scott Allen (or better ;-))! Amazing!
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
That’s high praise. Thank you.
@RayGarza-sr3zj
@RayGarza-sr3zj 10 ай бұрын
Hi Tim, I like using Interfaces and I still had a mind-blowing experience after watching this tutorial. Love learning ...
@IAmTimCorey
@IAmTimCorey 10 ай бұрын
Great to hear!
@steamerSama
@steamerSama Жыл бұрын
If we are going to cast the object as IDigitalProductModel to access TotalDwnloadsLeft anyways at 36:00, we might as well store List and cast to IProductModel as well. If we think of a case where there are 10 interfaces implementing IProductModel, then we'd have 10 _if (prod is InterfaceImplementingIProductModel variableName)_ assignments, more in some cases. Shouldn't there be a better way to encapsulate this logic inside the interface themselves?
@steamerSama
@steamerSama Жыл бұрын
I kind of figured out why this example has been bothering me. Technically speaking, IProductModel should actually be IPhysicalProductModel, because it's ShipItem is unique to physical products and therefore should not be a part of the base interface. The base should have something like _void Checkout();_ and IPhysicalProductModel should implement it as ShipProduct() and IDigitalProductModel should implement it as DownloadItem() or somewhere along those lines. This way, the list can have the base class, just call Checkout() on it and each item would call it's defined method. interface IProduct { string name { get; } void Checkout(); } interface IPhysicalProduct : IProduct { void ShipItem() { Debug.Log("Shipping item"); } void IProduct.Checkout() { ShipItem(); } } interface IDigitalProduct : IProduct { int totalDownloadsLeft { get; } void DownloadItem() { Debug.Log($"Downloading item; {totalDownloadsLeft} downloads left"); } void IProduct.Checkout() { DownloadItem(); } } class PhysicalProd : IPhysicalProduct { public string name { get { return "productName"; } } }
@jonathanlusby4213
@jonathanlusby4213 Жыл бұрын
Thanks Tim, I have been aware of interfaces for a while but didn't really understand why I should use them. Now I get it. Thanks you for the clear explanation and examples.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
I am glad it was helpful.
@drift9365
@drift9365 3 жыл бұрын
Hi Tim, been struggling to understand Interfaces, this is about my 4th video on them, "it's a contract" doesn't help me :). Would it be correct to say "an interface is structural inheritance, that adds a layer of abstraction"?
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
It sounds like you are thinking too abstractly. An interface says that a class will have certain attributes. When you use an interface as an object type, you will only have access to those attributes because that is all you know that it has. However, that is a benefit because any class can go into that object, as long as it implements the interface. The IDisposable interface is probably the best example of this. That interface says that a class implementing it will have a Dispose method. That's it. The benefit of having that interface is that we can then apply it to any class we want and know that the class will have a Dispose method. We use this in using statements. For example, we might have this code: using (MyClass test = new MyClass()) { } Now, when the code inside the curly braces completes, the "using" statement will call the Dispose method in our "test" object. How does it know to do that? Because it implements IDisposable (otherwise, we cannot use the using). Microsoft wrote the using statement. They didn't write your code. Yet, Microsoft's code can call your code's Dispose method because it implements an interface Microsoft created. That's why a contract is the most common way of visualizing it. By implementing IDisposable, you are agreeing that you will have a Dispose method. That is the contract you are signing.
@rconte
@rconte 3 жыл бұрын
Let me state my vision on that (does not mean it is correct, just the way I see it... A property is something like... (3 below) public string Make {get; set;} public string Model { get; set; } public string Year { get; set; } A method is something like... public bool Equals(Car car) { return (this.Make, this.Model, this.Year) == (car.Make, car.Model, car.Year); } A method SIGNATURE is something like... public bool Equals(Car car) (looks like a method without the instructions, just the header...) An interface is a set composed of --some properties and --some method signatures, for example public int xxxx {get;set} public bool yyyy {get,set} public string zzzz (int number) Normally with a name starting with I, say ISomething (but not a must) One may write classes (ex Class CCC) that implement the properties and the methods, witch means it has the same properties and method WITH the "signature" (top line) of the interface. Thats free. (and nobody needs to know) Besides that, if you write "CCC : ISomething" - the name of an interface after the class name, the C# compiler will now you intend to implement the interface ISomething and check for that to help you do it right, and complain if there is some properties or some methods missing... By the way, this is one common thing to do... And what is the use for that? Well one example is the example in the video above... In a nutshell you write code referring to the named interface (ISomething) and that named interfaced is replaced by classes that the compiler knows (you told it) that implements it... ----------------------------- Bur remember, this is only my view of the thing that I dare to show. I hope those that in fact know the subject may correct it... until then...
@rconte
@rconte 3 жыл бұрын
One more note: I did not know what an interface was until I saw this video, maybe I still do not know...
@YOUTUBE_IS_WOKE
@YOUTUBE_IS_WOKE 3 жыл бұрын
This example solidified my understanding on interfaces, the clear explanations and the addition of c# 7 new features. Tim is really amazing. The 97 dislikes most probably are beginner developers who are finding it hard to grasp what interfaces are useful for. Cheers
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 жыл бұрын
Maybe! When you are a beginner, its hard to find the right order of topics to study and can be frustrating when a topic you want to learn is presented in a way that assumes prior knowledge/training. Tim organizes his play lists to help folks in that learning process - anyone interested can check those playlists out at Tim's YT channel page - kzbin.info/door/-ptWR16ITQyYOglXyQmpzw
@YOUTUBE_IS_WOKE
@YOUTUBE_IS_WOKE 3 жыл бұрын
@@tomthelestaff-iamtimcorey7597 Hi Tom, may I please request you to ask Tim if it is possible to make a tutorial on Web Api authentication with JWT using Azure Active Directory? Maybe a request to be included in future videos? Thank you
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 жыл бұрын
​@@KZbin_IS_WOKE Added to the list for Tim's consideration!
@BijouBakson
@BijouBakson 2 жыл бұрын
I used to wonder what IEnumerable was; now I know it's an interface. Oops! Why does it seem like there's always something that I didn't understand? :) Thanks for this one, it helped clear some clouds.
@rajeshpandhare2638
@rajeshpandhare2638 4 жыл бұрын
I tried to learn and understand Interfaces from Paid courses first, but this lecture from Tim, explains it so cool and easy. Thank you Tim, it really helped me to understand the concept and where to use Interfaces.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Glad it was helpful! That is why I do this, to make learning easier.
@tresaidh3y90
@tresaidh3y90 3 жыл бұрын
This was the best explanation on interfaces I have ever received. Thank you Tim for all your videos you are really helping me launch my career as a .C# dev
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
You are welcome.
@torrvic1156
@torrvic1156 Жыл бұрын
You are truly a miracle for anybody learning CSharp Tim! I’ve learned so much stuff from your videos! I loved that you showed advanced technique when one interface can implement the other and then you can see methods and other stuff implemented in some concrete instance implementing one of this interfaces. Brilliant! Thank you so much GREAT teacher! I hope that you are a very rich man because you truly deserve it!
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome.
@neveobardo1853
@neveobardo1853 3 жыл бұрын
Hey Tim! I got the idea of how to use Interfaces but i still didn't get why it works different from a super asbtract class with abstract methods. On this example, we could make the ProductModel class and put the abstract statement on ShipItem method. So, in the child classes we would override it to what they should really do. Why use Interfaces on this case?
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Couple of reasons. First, an abstract class implies a relationship (object a "is a" b). That isn't always true. Second, you can only inherit from one class. You can implement multiple interfaces. Here is a quick example: IDisposable. This is an interface created by Microsoft. It has one method definition in it: Dispose(). If you implement that class, you can us a "using" statement to ensure that your class gets disposed of properly. Microsoft does not know about your class, yet you can implement their interface and they can call a method on your class. If you tried to do this with inheritance, you could never inherit from another class if you wanted to be disposable.
@squirrel1620
@squirrel1620 3 жыл бұрын
Yep that's it. 26:16 and it finally clicked how interfaces can be useful, thank you you're a god
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Awesome! I’m glad it was helpful.
@HaileeMiu
@HaileeMiu 4 жыл бұрын
minute 21:00 - "OOOOOOOOOOOOOOO" finally I get a real like reason for interfaces
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Excellent!
@nickbarton3191
@nickbarton3191 5 жыл бұрын
Hi Tim, Good video. Thanks for making this tutoring free and public. Good explanation of implementation of multiple Interfaces over inheritance. Another use for Interfaces that I use a lot is decoupling and dependency injection. So for example an object Factory creates an object that implements an Interface(s) which hides the injection of other objects that it may depend on. The Factory get object method only depends on the Interface and so does the application that uses it. So, all the wiring up of the object of all of its dependencies are hidden from the application. This allows for a very flexible solution where the architecture of object and its dependancies can be changed without having to change the application. When testing the application a mock object can be used which is another advantage.Hope that makes sense. I think that you alluded to that towards the end. Look forward to your next video on this topic, like you I'm self taught and maybe there is another usage I missed.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
I've got a video on the Dependency Inversion Principle (the D in SOLID) that covers the factory pattern. I also have a video on Dependency Injection which takes it a step further by using a DI system instead of a manually-created factory.
@Mohie.Essingery
@Mohie.Essingery Жыл бұрын
Wouldn't if(prod is DigitalProductModel digital) works too? Without needing an extra interface 35:40
@IAmTimCorey
@IAmTimCorey Жыл бұрын
It would work, but you would then be hard-coding it to only work with DigitalProductModel. If you had mocked an IDigitalProductModel for unit testing, it would not work here.
@FredrikBergman
@FredrikBergman 6 жыл бұрын
Thanks Tim for creating all these well explained and easy to understand videos. They are really great!!
@IAmTimCorey
@IAmTimCorey 6 жыл бұрын
I appreciate the kind words.
@anthonyj777
@anthonyj777 Жыл бұрын
Thank you very much, lots of penny's dropped :)
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Great!
@andreymtrx8368
@andreymtrx8368 4 жыл бұрын
This channel is really the best at .net. If English was my native language, my joy would have no bounds, in some moments it is difficult to understand the whole essence because of the language barrier. But man.. keep it up pls
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
I am glad it is so helpful.
@ardavaztterterian1211
@ardavaztterterian1211 5 жыл бұрын
Great explanation. You are one of the few tutors who are clear in their explanation. Thank you, but why your online courses are so damn expensive? It would be amazing if you do some sales or provide sale coupons.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
I do offer sales to my mailing list members and occasionally to the public as a whole once or twice a year. The cost is relative. If you are looking at it compared to a free course or a $10 Udemy course then yes, they are expensive. If you are looking at them in comparison to a college course then they are cheap. My Foundation in C# course series is essentially about 3 semesters worth of teaching (two and a half if you pushed it). Besides, not all training is created equal, just like not every car is the same. Just because a run-down Ford has four wheels and goes when you push the gas doesn't mean that a Mercedes should cost the same because it too has four wheels and goes when you push the gas.
@fordfiveohh
@fordfiveohh 5 жыл бұрын
Because he doesn't suck .... And this one video probably saved me 5 hours of spinning....
@TonyVirili
@TonyVirili 5 жыл бұрын
Excellent explanations. Terrific examples. I'm much more confident in knowing when to use these. Thank you!
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Awesome!
@danielhadad4911
@danielhadad4911 4 жыл бұрын
Thanks! This was enlightening.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Glad it was helpful!
@박소윤-c5f
@박소윤-c5f 5 жыл бұрын
It is the best demonstration of "Why we need to use the Interface"
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Thank you!
@newabyuser
@newabyuser 6 жыл бұрын
why i like Mondays..Thanks to you
@IAmTimCorey
@IAmTimCorey 6 жыл бұрын
Awesome! I'm glad I can improve Mondays for you.
@harag9
@harag9 6 жыл бұрын
Agree, it's the best thing about Mondays ! Thanks Tim!
@Robotron2084Guide
@Robotron2084Guide Жыл бұрын
Thank you so much for these well-thought out and properly paced demo discussions. It helps the abstract feel much more concrete when creating mental images for coding. thanks again! Greatly appreciate your content.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome.
@israell9320
@israell9320 2 жыл бұрын
Thanks!
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Thank you!
@matterece3164
@matterece3164 6 жыл бұрын
Thanks! Because of this video I now understand what's the point of interfaces in creating applications
@IAmTimCorey
@IAmTimCorey 6 жыл бұрын
Awesome!
@mizantednioc
@mizantednioc Жыл бұрын
Thank you
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome.
@ELENTE_
@ELENTE_ 3 жыл бұрын
Best teacher in the universe!! Hands down
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 жыл бұрын
High praise!
@LIGHTBLESSINGFOREVER
@LIGHTBLESSINGFOREVER 4 жыл бұрын
JESUS LOVES YOU!! People like you are gifts from God. I hope you're saved. And thank you for these videos GOD BLESS YOU!! JESUS LOVES YOU!!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You are welcome.
@ArkFen
@ArkFen 4 жыл бұрын
man, I am not sure about Tim, but I can tell you 100% - I am saved... but I prefer not to do overkill preaching off topic and I would recommend you to do the same unless Jesus Himself explicitly told you to tell the Tim all of that... in which case I guess the private message still do the best... with all my respect, no offence and it is up to you what to do with your life, but again I believe there are many other ways to say thank you and to preach, without so many capital letters and repeating words... God bless bro!
@PDXpackrat
@PDXpackrat 5 жыл бұрын
You have truly changed my life :) Thank you, thank you. I've been struggling, as a new OO developer, to get a handle around what the purpose of Interfaces are. You made it very easy to understand.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Awesome!
@AcidVienna
@AcidVienna 22 күн бұрын
Tim, damn - BY FAR the best video explaining this topic I saw yet! Thanks a lot! And, even it exists for some time already -> your Advanced Topics playlist rulez!
@IAmTimCorey
@IAmTimCorey 18 күн бұрын
Thank you!
@mazingguitar
@mazingguitar 4 жыл бұрын
Wow Tim. Your materials are real eye-openers. Came here beacuse I had started learning design patterns and could not understand usage of interfaces... Thankfully you made me understand how it works. Subbed. Definitely coming back for more.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Great to hear!
@rodrigo6459
@rodrigo6459 6 жыл бұрын
That demo Sir was JUST BEAUTIFUL!!!! finally i get why some programmers use interface as type for objects!
@IAmTimCorey
@IAmTimCorey 6 жыл бұрын
Awesome!
Увеличили моцареллу для @Lorenzo.bagnati
00:48
Кушать Хочу
Рет қаралды 8 МЛН
From Small To Giant 0%🍫 VS 100%🍫 #katebrush #shorts #gummy
00:19
How many people are in the changing room? #devil #lilith #funny #shorts
00:39
coco在求救? #小丑 #天使 #shorts
00:29
好人小丑
Рет қаралды 20 МЛН
Inheritance vs Interfaces in C#: Object Oriented Programming
49:41
IAmTimCorey
Рет қаралды 104 М.
Master C# Interfaces in 12 Minutes - Beginner Tutorial
11:37
tutorialsEU - C#
Рет қаралды 24 М.
C# Dependency Injection with Autofac
54:45
IAmTimCorey
Рет қаралды 297 М.
Intro to Records in C# 9 - How To Use Records And When To Use Them
1:19:44
What are Interfaces? (C# Basics)
13:54
Code Monkey
Рет қаралды 212 М.
Увеличили моцареллу для @Lorenzo.bagnati
00:48
Кушать Хочу
Рет қаралды 8 МЛН