Interface in C#

แชร์
ฝัง
  • เผยแพร่เมื่อ 17 ต.ค. 2024

ความคิดเห็น • 174

  • @dnfvideo
    @dnfvideo  3 ปีที่แล้ว +1

    30 Important C# Interview Questions : th-cam.com/video/BKynEBPqiIM/w-d-xo.html
    25 Important ASP.NET Interview Questions : th-cam.com/video/pXmMdmJUC0g/w-d-xo.html
    25 Angular Interview Questions : th-cam.com/video/-jeoyDJDsSM/w-d-xo.html
    20+ SQL Server Interview Questions : th-cam.com/video/SEdAF8mSKS4/w-d-xo.html
    5 MSBI Interview Questions : th-cam.com/video/5E815aXAwYQ/w-d-xo.html

  • @adityaghosalkar431
    @adityaghosalkar431 6 ปีที่แล้ว +51

    One of the best explanation I have ever seen about Interfaces Thank You so much

  • @250miles2
    @250miles2 ปีที่แล้ว

    This has to be the absolutely best video I've seen on interfaces. No contest. Every video has failed to show how code reuse actually happens and, really, how "multiple inheritance" occurs, when usingan interface. For me, the missing link was the Factory design pattern... I've watched this video about 4 times now, and every time I watch it, I pick up something new. Thank you for creating this!! Truly amazing work.

  • @swingymcswing
    @swingymcswing 6 ปีที่แล้ว +6

    Now that I've heard this, I feel like I understand more than before. Didn't really realize there were implicit contracts and that multiple interfaces can happen after app is in production to add new features and not break existing interfaces. Very nice explanation.

  • @rohityadav5802
    @rohityadav5802 3 ปีที่แล้ว +3

    The First Time I could understand the actual use of the interface, Excellent explanation thank you very much for this video.

  • @pickle1987
    @pickle1987 6 ปีที่แล้ว +19

    From my point of view, Interfaces are used mainly to implement Polymorhpisme, they are very useful to decouple your code base (if you are using an IoC framework) by injecting the interface representing your concrete Presenter/Service or whatever you want, and lastly if you write unit tests with Microsoft Fakes you will need them to generate your stubs

    • @dnfvideo
      @dnfvideo  6 ปีที่แล้ว +9

      Polymorphism exists because of parent child relationship. With out inheritance there is no polymorphism.I an create a parent simple base class and still do DI for child classes.
      Decoupling is a product of polymorphism. Polymorphism gives the ability to run objects differently under different conditions and thus hiding the concreteness.
      With simple base class i can still do plymorphism and DI.I do agree interfaces gives you a very generic structure as compared to simple class where you will have some base implementation.
      SimpleClass x = new SimpleChildClass1();
      x.Method1();
      x = new SimpleChildClass2();
      x.Method1();

    • @markanthonysabado9632
      @markanthonysabado9632 4 ปีที่แล้ว

      Real world scenario we use Interface because of polymorphism and swappable component.

    • @jonathansaindon788
      @jonathansaindon788 ปีที่แล้ว

      @@dnfvideo parent child relationship has more to do with inheritance than polymorphism. Interfaces are the simplest and cleanest way of achieving polymorphism.

  • @MichaelRainabbaRichardson
    @MichaelRainabbaRichardson 5 ปีที่แล้ว +2

    Great video as others have said!
    I needed it as a bit of a refresher and at the end I wonder if others might appreciate another perspective on interfaces. I look at the interface as a declaration of what my class should be while the class is the implementation of that design. Contract is incredibly appropriate when looking at it from the perspective of consumption, but if you are developing from a purely OOP perspective, interfaces represent the abstract of how an object should present itself ("what") while the class describes the actual solution ("how").
    In these examples, the interfaces were extracted from the class, but from a design perspective, you would logically define your entities, then build your interfaces to start solidifying the design, then you would begin to build your classes using those interfaces as schema/blueprint/outline to create actual behaviors.

  • @balamurugankalyanasundaram426
    @balamurugankalyanasundaram426 5 ปีที่แล้ว +3

    Nice article about the interfaces. I have few questions.
    1.Instead of Factory pattern, we can choose any other patterns like abstract factory or resolver or DI?
    2.Will abstract class solve the same problem discussed here? if it so, what are the other advantages to prefer interfaces?
    3.Can we use abstract classes for dependency injection?

  • @adapass
    @adapass 2 ปีที่แล้ว

    Awesome explanation of interface. I have never seen any article in google explaining the need of interfaces like this in a clear very simple way. Even a programmer with a very little knowledge on c# or oops can understand this. You are rocking. Please keep posting c# videos like this.

  • @AmitKumar-mt9mf
    @AmitKumar-mt9mf 5 ปีที่แล้ว +5

    One of the best explanation of Interface over the internet. Thanks you so much for creating this video.

  • @FeroChau
    @FeroChau 6 ปีที่แล้ว +2

    In my perspective, an interface is mainly used for achieving flexible object composition which is one of the core concept in Elements of Reusable Object-Oriented Software. Also, I think the primary benefit of an explicit contract is that it could provide loose coupling, flexibility and interchangeability of the implementation methods. It could also reduce the compile time but I don't think it is the main reason of using an interface.

  • @CyberAbyss007
    @CyberAbyss007 4 ปีที่แล้ว

    Thank you for this video. Just took a live online class last week so its sort of fresh in my head. It took me a bit to get it. Interfaces are like server side include templates but when we say contract just means the class template is enforced from a signature perspective. You don't put any code in the interface so its only useful depending on the circumstances. If you have a large code base with lots of classes with similar functionality then use interfaces so you can enforce class signatures and modify them as needed and if you want to consume less info than is in the base class. Again, thanks for the video.
    Creating classes as abstract all you designate classes as optional (can be overridden) in the using class using the override keyword.

  • @manishjawarkar84
    @manishjawarkar84 5 ปีที่แล้ว +4

    Best explanation for Interface and Clear all my doubts. Thank you so much.

  • @HeathInHeath
    @HeathInHeath ปีที่แล้ว

    Thank you for this video. I found your explanation and discussion to be very helpful in building my awareness of which situations would benefit from adding the abstractions of interfaces or the factory pattern.

  • @Imrankhan-nn5kp
    @Imrankhan-nn5kp 5 ปีที่แล้ว +8

    The Best video over the internet on interface. Thank you so much . It helped a lot.. keep going brother.

  • @kopilkaiser8991
    @kopilkaiser8991 ปีที่แล้ว

    Thank you for the video. I am watching it from London. I have learnt a great deal about C# interfaces.

  • @gauravvijaygupta6240
    @gauravvijaygupta6240 4 ปีที่แล้ว +1

    It is my first time when i watch your video and it is my best experience now i will watch more video on different topic.

  • @fredmassey1062
    @fredmassey1062 3 ปีที่แล้ว

    The best explanation I have found for understanding interfaces, and why they are used. Thank you.

  • @marziehfatemi7615
    @marziehfatemi7615 2 ปีที่แล้ว

    Thanks for this video. I think the most important usage of the interface is for dip, Ioc and interface segregation rules of solid. and this happens when we create multiple layers when one layer needs another and we want to decouple them to loosely coupling.

  • @bachelorcookingandeating1918
    @bachelorcookingandeating1918 3 ปีที่แล้ว

    One of the best examplaction on the interface. This is the right way to use interface in real development
    Thank you so much sir ...
    For grate session

  • @PankajChauhan-jx1ie
    @PankajChauhan-jx1ie 5 ปีที่แล้ว

    I have so much doubt on interfaces...because if they only contains signatures then why we can't use these methods direct from class...but i really appreciate the concept of caller and callee.....it clears my all doubts regarding interfaces..thankyou so much..

  • @emmadkareem5247
    @emmadkareem5247 4 ปีที่แล้ว

    Thanks for your efforts. I see that removing the factory and dynamic concepts would have made your point much clearer.

  • @srikplaylist
    @srikplaylist 5 ปีที่แล้ว +1

    It looked like greek language before watching this video, now it looks so simple. Thanks a TON!!!

  • @tonygoyal5781
    @tonygoyal5781 6 ปีที่แล้ว +2

    One of the best explanation on any topic ,i have ever seen. Thanx alot sir..

  • @nisargshah5485
    @nisargshah5485 4 ปีที่แล้ว

    I have seen lots of videos regarding this topic,but this is a best explaination ever about interface 💯

  • @Sunstriderko
    @Sunstriderko 4 ปีที่แล้ว +1

    definitely the best video about interfaces out there. Thanks for amazing job

  • @adapass
    @adapass 5 ปีที่แล้ว +1

    Awesome explanation for even experienced programmers with very simple sample program.

  • @manjitsarma6592
    @manjitsarma6592 4 ปีที่แล้ว

    This is it(end of all confusions surrounding Interface)..Awesome video.Thanks !!

  • @faisalkhanjalalia1966
    @faisalkhanjalalia1966 5 ปีที่แล้ว +1

    Great explanation!
    However it would be a cherry on top if you could discuss about access modifiers while implementing interfaces.

  • @salmanahmad2532
    @salmanahmad2532 2 ปีที่แล้ว

    20:01: Correction: Interfaces contain only method declaration and not the definition. This means by default all the methods in an interface are the abstract method and public. Great explanation.

    • @salmanahmad2532
      @salmanahmad2532 2 ปีที่แล้ว

      @.NET Interview Preparation videos

  • @Hehe-k6j
    @Hehe-k6j 4 ปีที่แล้ว

    Prasad Sir,
    Its great video and very good, clear and clarity explanations.
    Really, all my doubts are cleared regarding interface.
    Great Job,
    Thanks.

  • @selvaa5876
    @selvaa5876 5 ปีที่แล้ว +2

    Really very good explanation about Interface. great session. Thank you so much !!!

  • @swarupkrsinha
    @swarupkrsinha 6 ปีที่แล้ว +1

    Thank you for the tutorial. I have a doubt: what do you suggest- Isn't wrong calling interface does "Inheritance". Inheritance is something we inherit from parents (in real world also), and which can be possible using Base class or abstract class. Using Interface its always "Implements" the properties or method from interface, even if we add multiple interface in a derived class, still it should call multiple implementation. I may be wrong, please clarify it.

    • @dnfvideo
      @dnfvideo  6 ปีที่แล้ว

      yes i slipped at one place....Interfaces are always implemented.....

    • @swarupkrsinha
      @swarupkrsinha 6 ปีที่แล้ว

      Thanks!

  • @rohityadav5802
    @rohityadav5802 3 ปีที่แล้ว

    Best video on the interface over youtube

  • @MrBivanovs
    @MrBivanovs 11 หลายเดือนก่อน

    The best description about subject

  • @avinashgoyal8243
    @avinashgoyal8243 3 หลายเดือนก่อน

    Best video for Interface I ahve ever seen!!

  • @TellaTrix
    @TellaTrix 6 ปีที่แล้ว +2

    Such superb explanation sir, We usually used interface for decoupled entity, but there has lot of things that we could use with interface.

  • @abhishekr8021
    @abhishekr8021 2 ปีที่แล้ว

    Thanks very much for making me understanding interfaces uses in realtime.

  • @nishanthgmk3487
    @nishanthgmk3487 3 ปีที่แล้ว

    Awesome explanation, can you make a video about Startup.cs, DI, constructor injection, overriding, etc. Your videos are the best to understand. Thanks for the great video

  • @soomon3608
    @soomon3608 6 ปีที่แล้ว +2

    Thank you so much for this video. I think I finally understood what interfaces are used for!

  • @renzybi5061
    @renzybi5061 3 ปีที่แล้ว

    Best explanation of this topic! And ive seen alot. You have a knack for teaching brother! Many thanks

  • @huntervanguard6423
    @huntervanguard6423 6 ปีที่แล้ว +1

    Helped greatly with my understanding of how interfaces are to be used. Thanks a lot.

  • @pushpakshah4141
    @pushpakshah4141 6 ปีที่แล้ว +1

    How Abstract class will get used in same example, for e.g. will be used in place where you shown abstraction with interface ?

  • @meenubatra6283
    @meenubatra6283 5 ปีที่แล้ว +1

    Such a nice explanation of interface.Sir can you make a video on abstract class vs interface because abstract class can do whatever interface can do except multiple inheritance.

  • @husamdarwish7009
    @husamdarwish7009 5 ปีที่แล้ว +1

    Thank you so much
    Very clean and clear explanation
    Keep explaining mind defusing ideas in C#

  • @kiransaravade5127
    @kiransaravade5127 2 ปีที่แล้ว

    great explanation .. shiv sir u cleared my wrong assumption about interfaces

  • @RollinShultz
    @RollinShultz ปีที่แล้ว

    It does seem like Interfaces are great for separating concerns and also implementig methods not defined in the base class. I suppose they are mostly used to coommunicated view to viewModel etc.
    If I want to make a small application that's specific to a type of person, so using you maths model, let's say I want to use a math class for an application that calculates volumme of concrete to order for a job. I have the basic math class with +,-,*,/ methods, and an interface that implements the advanced maths for calculus and trig functions, and for my contractor who doesn't have any use for those advanced features, I make an interface for concrete calculating methods for volume, and square footage etc. which are relevant to the contractor application. It certainly makes the maths class smaller and eliminates the bloat which would be caused by including unneeded advanced methods. Maybe it utilizes a mobile phone UI so we want to keep the phone app small. However, we want the phone app to be part of a greater application product. Interfaces then would be better than multiple applications all from scratch.

  • @NirajTiwariYoutube
    @NirajTiwariYoutube 3 ปีที่แล้ว

    Best explanations- first time I have learn about interface in actual

  • @sistemamarco
    @sistemamarco 3 ปีที่แล้ว

    Finally a good explanation. Good job.

  • @JohnStephen7
    @JohnStephen7 4 ปีที่แล้ว

    A great explanation about interfaces and its benefits. Thank You so much

  • @tauseefahmed2680
    @tauseefahmed2680 4 ปีที่แล้ว

    the best example and explanation I found here about the interface , thank you :)

  • @hansdevelde6326
    @hansdevelde6326 2 ปีที่แล้ว

    Thanks for this very clear explanation !

  • @omkarn2785
    @omkarn2785 4 ปีที่แล้ว

    I have one doubt sir in this video
    By default interfaces are public right ? Why using public keyword
    Can you please explain

  • @samadhanphad5683
    @samadhanphad5683 4 ปีที่แล้ว

    This is the great explanation on interface I ever seen , thanks for the video.

  • @yogeshwargoswami
    @yogeshwargoswami 5 ปีที่แล้ว

    Really help me to understand the interface..... What exactly the interface is.

  • @vsrrawat7954
    @vsrrawat7954 2 ปีที่แล้ว

    Great explanation.....i like it very much....Thank you for this

  • @olympustech346
    @olympustech346 3 ปีที่แล้ว

    hi new to interfaces, why did we connect the interface to the math-component and remove factory

  • @SeanSmith73
    @SeanSmith73 3 ปีที่แล้ว

    Superb presentation - thank you.

  • @achilleskocaeli
    @achilleskocaeli 4 ปีที่แล้ว +4

    Respect. After that video, I learnt interfaces. I am now immortal.

  • @yousufanwer99
    @yousufanwer99 3 ปีที่แล้ว

    Best Explanation ever ,Please make video on polymorphism

  • @umerwaqas5943
    @umerwaqas5943 3 ปีที่แล้ว

    That was just amazing opinion sir. Nicely explained.

  • @nkp107
    @nkp107 6 ปีที่แล้ว

    thanks sir, I think now no need to read more about interfaces. Everything is clear now.

  • @VikasKumar-jk5yh
    @VikasKumar-jk5yh 4 ปีที่แล้ว

    Explained very well and elegantly..

  • @ranadheera7574
    @ranadheera7574 4 ปีที่แล้ว

    This is real tutorial, superb.

  • @sanketnaik2825
    @sanketnaik2825 6 ปีที่แล้ว +2

    Hi sir,
    Can you please make a practical video on SOLID properties....

  • @fahadgolra1219
    @fahadgolra1219 3 ปีที่แล้ว

    I really liked the video and the way things are explained. However, I do not agree with the final remarks that interfaces are only used when components are not in direct link with each other. They are also important for some of the design patterns like for example the strategy pattern.

  • @harishpoojary9183
    @harishpoojary9183 6 ปีที่แล้ว +1

    Very clear presentation on interface. Thank you.

  • @imadabab
    @imadabab 4 ปีที่แล้ว

    Good explanation. But I create an interface for every sub class to apply Dependency Injection. So I inject the interface in any UI implementation of the sub class.

  • @asishdas6267
    @asishdas6267 5 ปีที่แล้ว

    Don't we use multiple inheritance nature of interfaces to enable our working class to access methods from two different class libraries? Let's say if you had a logging library that you would want to use every time you do math operations.

  • @balamuruganp3865
    @balamuruganp3865 5 ปีที่แล้ว

    Excellent excellent , after watching this completely understand about interface, feeling great and confident on this. Thank you sir.

  • @pkplaypal
    @pkplaypal 6 ปีที่แล้ว

    So as per your statement we cant say that contract is interface i got that again then we cab say that Explicit contract is interface because as to overcome the situation of that alert issue to notify changes we need interface and thats why need explicit contract so can we say that interface as explicit contract ??? please do let me know thanks

  • @sarathbaiju6040
    @sarathbaiju6040 4 ปีที่แล้ว

    Great video. Interface is also helpful for unit testing

  • @aagebadho6907
    @aagebadho6907 3 ปีที่แล้ว +1

    Adding to all the points, Interfaces are required for dependency Injection ( which also helps us to do Unit Testing)

  • @sanjaikhola7184
    @sanjaikhola7184 5 ปีที่แล้ว

    Nice video very good explanation about Interface help for me a lot.

  • @mohaithi
    @mohaithi 4 ปีที่แล้ว

    very good explanation about interface. Now I understood Interface when and where to use. Thanks a lot shiv!!

  • @tusharkantidas4622
    @tusharkantidas4622 4 ปีที่แล้ว

    best explanation on interface I've ever read... Thank u Shiv :)

  • @ZiaurRahmanAdvocate
    @ZiaurRahmanAdvocate 5 ปีที่แล้ว

    Good presentation. I would also like to see a discussion on more than 4-5 interfaces working together with some Database connectivity examples. May be a real life case can be reviewed as well.

  • @navidkh1883
    @navidkh1883 3 ปีที่แล้ว

    This is an awesome video. 👌 thanks very much.

  • @priyankakulkarni84
    @priyankakulkarni84 2 ปีที่แล้ว

    Wonderful 😊. Many thanks

  • @jithinm5692
    @jithinm5692 5 ปีที่แล้ว +1

    Thank you for the clear explanation

  • @learnwithmoonlight4463
    @learnwithmoonlight4463 3 ปีที่แล้ว

    Thank you so much for such nice explanation!!

  • @KDOERAK
    @KDOERAK 5 ปีที่แล้ว +2

    A great video: clear explanation, good examples! thx

  • @satish123mattaparti
    @satish123mattaparti 5 ปีที่แล้ว +2

    Thank you best explanation, now i can feel the use the interface

  • @amithaacharya
    @amithaacharya ปีที่แล้ว

    what a video!! Just loved it.

  • @fooballers7883
    @fooballers7883 9 หลายเดือนก่อน

    Thank you for a very detail explanation about interfaces...

  • @ankurkamthan5854
    @ankurkamthan5854 4 ปีที่แล้ว

    Cleared many doubts today

  • @PushpendraKumar-hy5pd
    @PushpendraKumar-hy5pd 4 ปีที่แล้ว

    Love this videos ! Nice explanation of Interfaces.

  • @yogeshnainwal8319
    @yogeshnainwal8319 3 ปีที่แล้ว

    it ' too good explanation about interface.

  • @geirO2
    @geirO2 4 ปีที่แล้ว

    Good work, explains it very well...

  • @Ahmet-nd5ct
    @Ahmet-nd5ct 3 ปีที่แล้ว

    Great explanation.thnls

  • @saitejaadepu0811
    @saitejaadepu0811 2 ปีที่แล้ว

    Good explanation thanks sir....

  • @bhatdinesh
    @bhatdinesh 4 ปีที่แล้ว

    Very nicely explained

  • @dgowtham5290
    @dgowtham5290 6 ปีที่แล้ว

    Your teaching way is awesome.

  • @vinokarthik99
    @vinokarthik99 5 ปีที่แล้ว +1

    Thank you so much... You made it very clear

  • @davsx6201
    @davsx6201 4 ปีที่แล้ว

    Ooh great!! one of the best videos about interfaces

  • @sukhjinderpawar
    @sukhjinderpawar 5 ปีที่แล้ว

    Best explanation so far

  • @hemantkumartalasu9398
    @hemantkumartalasu9398 5 ปีที่แล้ว

    Very good explanation.

  • @tomy7424
    @tomy7424 4 ปีที่แล้ว

    I don't understand why implement a new interface when the change required is the same even if done with existing interface, seeing this example I know it's short in real world comparison but still, the change required was to implement new methods which is the same if multiply and divide methods were to add to IMaths , where else change is required? Just implementation of those new methods then we're ready to go? aren't we?

  • @stoic2454
    @stoic2454 4 ปีที่แล้ว

    Anyone knows who's the instructor in this video ?

  • @shashikantrajak1784
    @shashikantrajak1784 3 ปีที่แล้ว

    Even if you are using implicit conectarte you should use interface for mock testing and other purpose.