1 00:00:01,020 --> 00:00:06,960 ‫In this lesson, you will learn how to create and implement your own interfaces with a concrete example, 2 00:00:06,960 --> 00:00:13,200 ‫and you will get an idea of why interfaces are used, especially when our classes don't have a relationship 3 00:00:13,200 --> 00:00:16,860 ‫with each other and therefore they don't share a base class. 4 00:00:16,860 --> 00:00:20,040 ‫So inheritance as such is not an option. 5 00:00:20,490 --> 00:00:26,160 ‫Imagine that we are working on a video game where the player can destroy stuff, but everything we destroy 6 00:00:26,160 --> 00:00:30,240 ‫will have different behavior depending on what is destroyed. 7 00:00:30,300 --> 00:00:37,260 ‫For example, destroying a chair will play some destruction sound and will spawn destroyed chair parts. 8 00:00:37,260 --> 00:00:44,190 ‫But destroying a car will play an explosion sound, create fire and destroy other objects nearby. 9 00:00:44,460 --> 00:00:51,600 ‫For our game, we have the following classes a chair that inherits from class furniture and the car 10 00:00:51,600 --> 00:00:53,700 ‫that inherits from class vehicle. 11 00:00:53,970 --> 00:00:56,190 ‫So let's look at those classes real quick. 12 00:00:56,340 --> 00:01:02,850 ‫So we have this chair which inherits from furniture, and the chair just has a simple constructor here 13 00:01:02,850 --> 00:01:09,360 ‫where we set the color as well as the material based on what is given to the object that is created. 14 00:01:09,570 --> 00:01:14,610 ‫But now, of course, this class is inheriting from furniture, which is why we have those properties 15 00:01:14,610 --> 00:01:17,880 ‫here, color and material that we just used in the chair class. 16 00:01:17,880 --> 00:01:22,350 ‫And then we have the constructor here, which is the default constructor, where those values will be 17 00:01:22,350 --> 00:01:23,160 ‫set by default. 18 00:01:23,160 --> 00:01:27,340 ‫So the color and the material will be white and wood by default. 19 00:01:27,360 --> 00:01:32,880 ‫And then we also have a simple constructor which uses the color as well as the material to set them 20 00:01:32,880 --> 00:01:33,750 ‫by default. 21 00:01:34,330 --> 00:01:41,430 ‫Okay, so there is nothing to fancy, but of course we also have a car and we want to be able to destroy 22 00:01:41,430 --> 00:01:43,830 ‫the chair and the car, as I stated earlier. 23 00:01:43,980 --> 00:01:46,140 ‫So let's look at the car real quick. 24 00:01:46,410 --> 00:01:53,640 ‫So here we have the same story, a subclass car that extends vehicle where we set the car speed as well 25 00:01:53,640 --> 00:01:54,510 ‫as the color. 26 00:01:54,510 --> 00:01:58,590 ‫So now we are using, by the way, a simple constructor as we do it here. 27 00:01:58,590 --> 00:02:04,830 ‫But of course, we could have used based here as well, passing the speed as well as the color. 28 00:02:05,220 --> 00:02:09,780 ‫So that is also a valid option and we wouldn't have to use this in here. 29 00:02:09,780 --> 00:02:13,050 ‫So there are two different ways, of course, to go about it. 30 00:02:13,650 --> 00:02:14,140 ‫Okay. 31 00:02:14,160 --> 00:02:19,320 ‫And then this car is inheriting from vehicle where of course, speed and color have to be defined. 32 00:02:19,320 --> 00:02:25,860 ‫So let's look at the vehicle class and we can see here that this base class vehicle has a speed, a 33 00:02:25,860 --> 00:02:31,920 ‫color, a default constructor, which sets those two values, speed with a 120 kilometers per hour and 34 00:02:31,920 --> 00:02:33,150 ‫the color with white. 35 00:02:33,150 --> 00:02:37,770 ‫And then we have the simple constructor which set the speed and the color based on the values that are 36 00:02:37,770 --> 00:02:40,470 ‫given to the vehicle object. 37 00:02:40,500 --> 00:02:45,000 ‫Also, of course, to the inheriting objects such as a car, for example. 38 00:02:45,540 --> 00:02:45,830 ‫Okay. 39 00:02:45,870 --> 00:02:51,750 ‫So now that we have all of those different classes and we saw how they are structured, let's look at 40 00:02:51,750 --> 00:02:53,880 ‫the actual destruction feature. 41 00:02:53,970 --> 00:02:58,670 ‫So what is the best approach to create such a destruction feature? 42 00:02:58,680 --> 00:03:05,220 ‫If we think about it, we can't add a class to make our classes inherit from it because C-sharp is a 43 00:03:05,220 --> 00:03:12,390 ‫single inheritance language and not a multi inheritance language we all already inherit from one class, 44 00:03:12,390 --> 00:03:18,060 ‫so the car already inherits from vehicle and the chair already inherits from furniture. 45 00:03:18,060 --> 00:03:20,370 ‫So it cannot inherit from something else. 46 00:03:20,370 --> 00:03:26,340 ‫Like, for example, the vehicle here, you see, C-sharp doesn't allow this because it cannot have 47 00:03:26,340 --> 00:03:28,050 ‫multiple base classes. 48 00:03:28,530 --> 00:03:32,010 ‫A class cannot have multiple base classes in C-sharp. 49 00:03:32,580 --> 00:03:39,300 ‫So plus there is no concrete relationship between a car and a chair to share one base class anyways 50 00:03:39,300 --> 00:03:42,390 ‫because they are entirely different to two things, right? 51 00:03:42,690 --> 00:03:48,780 ‫If we implement normal methods called the destroy method, for example, in each of those classes that 52 00:03:48,780 --> 00:03:51,510 ‫we have here, it will be hard to maintain. 53 00:03:52,200 --> 00:03:58,320 ‫What if we decide to change the destruction system entirely or add visual effects to our destructible 54 00:03:58,320 --> 00:03:59,550 ‫objects in the future? 55 00:03:59,820 --> 00:04:03,780 ‫It will be a pain to actually go through each class and modify it. 56 00:04:04,500 --> 00:04:08,340 ‫Because in this case, we only have two subclasses, so to speak. 57 00:04:08,340 --> 00:04:08,520 ‫Right. 58 00:04:08,520 --> 00:04:15,390 ‫But imagine you have 50 or even 100 different classes, 100 different types of objects in your game. 59 00:04:15,390 --> 00:04:20,280 ‫Then you would have to go through every single one of them and adjust the code accordingly. 60 00:04:21,280 --> 00:04:24,530 ‫So that is really a burden and we don't want to go through that. 61 00:04:24,550 --> 00:04:27,340 ‫That's why we need to find a better solution. 62 00:04:27,670 --> 00:04:34,060 ‫What we need is a way to enforce our distractible behavior on every class that uses it, just like a 63 00:04:34,060 --> 00:04:34,840 ‫contract. 64 00:04:35,080 --> 00:04:41,620 ‫And if you have watched our video on interfaces, you know that they are contracts that we can create. 65 00:04:41,770 --> 00:04:48,010 ‫So the best approach in this case is to use an interface and we will call it I Destroy Able. 66 00:04:48,010 --> 00:04:54,160 ‫And any class that implements this interface will be forced to follow our destruction requirements and 67 00:04:54,160 --> 00:04:58,300 ‫customize it at the same time, depending on the class itself. 68 00:04:59,380 --> 00:05:01,860 ‫So let's go ahead and create such an interface. 69 00:05:01,870 --> 00:05:08,860 ‫Therefore, you can go here to your project, add a new item, and then select interface right here 70 00:05:08,860 --> 00:05:10,090 ‫and give it a name. 71 00:05:10,090 --> 00:05:11,770 ‫So I'm going to call this one. 72 00:05:11,770 --> 00:05:20,200 ‫I d destroy ble so you can see when using interfaces you add the I at the beginning of the name of the 73 00:05:20,200 --> 00:05:23,890 ‫file to indicate that this is going to be an interface. 74 00:05:23,980 --> 00:05:25,900 ‫So let's add this interface. 75 00:05:26,110 --> 00:05:34,330 ‫So this interface will just have a property to store the audio file that will be run once we execute 76 00:05:34,330 --> 00:05:37,900 ‫the destruction, which will be the destruction sound. 77 00:05:38,140 --> 00:05:45,190 ‫And then we just have a method that will destroy an object and we're going to call this method destroy. 78 00:05:45,430 --> 00:05:48,520 ‫It will not return anything, it will just destroy something. 79 00:05:48,520 --> 00:05:52,510 ‫So it could, for example, return the graphics that you have. 80 00:05:52,510 --> 00:05:58,360 ‫So the objects that you want to display once the item is destroyed, for example, the car is destroyed 81 00:05:58,360 --> 00:06:00,370 ‫or the chair is destroyed and so forth. 82 00:06:00,880 --> 00:06:09,340 ‫So let's now make sure that our classes are in fact going to implement this interface and then, of 83 00:06:09,340 --> 00:06:14,950 ‫course implement the interfaces content, meaning the destruction sound as well as the destroy method. 84 00:06:15,190 --> 00:06:16,420 ‫How can we do that? 85 00:06:16,420 --> 00:06:25,390 ‫Well, let's go over to our car, for example, and here our car will need to add a comma here at the 86 00:06:25,390 --> 00:06:33,640 ‫top of the class definition at the top and use this I destroy able interface like so now if you add 87 00:06:33,640 --> 00:06:39,550 ‫that you can see that you get an error which says car does not implement interface member destruction 88 00:06:39,550 --> 00:06:45,040 ‫sound as well as destroy so we can show potential fixes and implement all members. 89 00:06:45,040 --> 00:06:49,780 ‫For example, this will create this automatic code for us. 90 00:06:50,080 --> 00:06:56,920 ‫So it will create the void, destroy, able destroy and it will create a destruction sound for us. 91 00:06:56,920 --> 00:07:02,290 ‫So that would be the auto generated version, but we can also do it manually. 92 00:07:02,290 --> 00:07:03,880 ‫There's no problem with that. 93 00:07:03,880 --> 00:07:07,480 ‫So here, for example, we can implement the destruction sound. 94 00:07:07,900 --> 00:07:14,830 ‫And then what I want to be able to do is I want to have a property to store the destroyed objects nearby. 95 00:07:14,830 --> 00:07:19,030 ‫So when a car gets destroyed, it should also destroy the nearby object. 96 00:07:19,030 --> 00:07:22,870 ‫And this list is also going to be of type. 97 00:07:22,870 --> 00:07:28,630 ‫I destroy able, which means it can store any object that implements this interface and we can only 98 00:07:28,630 --> 00:07:31,510 ‫access properties and methods in that interface. 99 00:07:31,510 --> 00:07:37,540 ‫So in order to create that, I'm going to create a public list of I destroy all objects and I'm going 100 00:07:37,540 --> 00:07:40,390 ‫to call them destroy balls nearby. 101 00:07:41,260 --> 00:07:45,910 ‫So now we can go ahead and extend our constructor. 102 00:07:46,000 --> 00:07:50,500 ‫So on one hand, we want to make sure that we initialize the sound. 103 00:07:50,500 --> 00:07:54,490 ‫So we make sure that we have an explosion sound. 104 00:07:54,520 --> 00:07:59,080 ‫For example, let's say we have this sound called car explosion sound amp three. 105 00:07:59,350 --> 00:08:04,090 ‫And then we want to initialize the list of destroy able objects. 106 00:08:04,090 --> 00:08:10,840 ‫So this will, for example, just be a new list of destroyed objects, and then we just need to also 107 00:08:10,840 --> 00:08:12,550 ‫implement the destroy method. 108 00:08:12,550 --> 00:08:13,660 ‫So this I destroy. 109 00:08:13,680 --> 00:08:18,010 ‫Well, here at the top you can see it's still not happy, it's still expecting us to implement the destroy 110 00:08:18,010 --> 00:08:18,550 ‫method. 111 00:08:18,580 --> 00:08:24,760 ‫So you see when you implement an interface you need to implement its members because the interface here 112 00:08:24,760 --> 00:08:28,120 ‫has two members, we need to implement both of them. 113 00:08:29,170 --> 00:08:35,920 ‫So that means that we need to go back here and we need to actually implement the destroy method. 114 00:08:36,070 --> 00:08:39,730 ‫So let's really quickly do that in order to do it. 115 00:08:40,060 --> 00:08:46,330 ‫What I want to add in here is going to be, first of all, two statements. 116 00:08:46,330 --> 00:08:48,100 ‫I'm just going to use right line statements. 117 00:08:48,100 --> 00:08:53,260 ‫I'm going to keep it simple because we're not creating a game here, but just trying to understand the 118 00:08:53,260 --> 00:08:54,880 ‫concepts of interfaces. 119 00:08:54,880 --> 00:09:00,280 ‫So when a car gets destroyed, we should play the destruction sound and create a fire effect. 120 00:09:00,280 --> 00:09:05,380 ‫So here we are just mimicking as if we would actually play the sound and it will just say, okay, playing 121 00:09:05,380 --> 00:09:09,490 ‫the car explosion amp three sound and then we create the fire. 122 00:09:09,490 --> 00:09:11,530 ‫So everything is under fire. 123 00:09:11,530 --> 00:09:13,840 ‫Everything is burning because the car is destroyed. 124 00:09:14,170 --> 00:09:20,620 ‫So now let's go through every single destroy all nearby and actually destroy it. 125 00:09:20,740 --> 00:09:28,010 ‫So here we're going to go through every single I destroy object that is inside of our list of destroyed 126 00:09:28,010 --> 00:09:29,110 ‫balls nearby. 127 00:09:29,500 --> 00:09:31,000 ‫We call it destroy all. 128 00:09:31,000 --> 00:09:37,120 ‫So every single item is going to be a destroyed ball, which is basically just a local variable name. 129 00:09:37,120 --> 00:09:45,040 ‫So we say, okay, the destroyed object that will implement the ID Storable interface will just be called 130 00:09:45,040 --> 00:09:47,080 ‫destroy ball in our for each loop. 131 00:09:47,080 --> 00:09:53,050 ‫So we iterate through it, which means we iterate through the collection, destroy balls nearby, which 132 00:09:53,050 --> 00:09:59,860 ‫is a list of I destroy objects, basically objects that implement the ID stretchable interface and then 133 00:09:59,860 --> 00:10:03,220 ‫we just call the destroy method. 134 00:10:03,760 --> 00:10:09,610 ‫So basically we create a chain reaction here, destroying everything around everything that is destroyed 135 00:10:09,610 --> 00:10:11,620 ‫and that is also a car and so forth. 136 00:10:11,620 --> 00:10:17,560 ‫So in this case, let's say we have two cars next to each other and they have a bunch of chairs next 137 00:10:17,560 --> 00:10:18,250 ‫to each other. 138 00:10:18,250 --> 00:10:24,520 ‫So the cars will call this destroy method where they will destroy the items nearby because, well, 139 00:10:24,520 --> 00:10:25,570 ‫it's a huge explosion. 140 00:10:25,570 --> 00:10:25,840 ‫Right. 141 00:10:25,840 --> 00:10:28,930 ‫There is a sound coming up and every item creates a sound. 142 00:10:28,930 --> 00:10:33,940 ‫Now, you could, of course, create a timer that it needs until the actual explosion happens after 143 00:10:33,940 --> 00:10:35,050 ‫something catches fire. 144 00:10:35,050 --> 00:10:36,790 ‫But we're going to keep it simple here. 145 00:10:37,330 --> 00:10:40,960 ‫So we're destroying the other cars, but also the other chairs. 146 00:10:40,960 --> 00:10:46,270 ‫So each car will infect other items surrounding it that are nearby. 147 00:10:46,270 --> 00:10:52,390 ‫And this could be, let's say, everything that is ten meters away or five meters away or however many 148 00:10:52,390 --> 00:10:56,350 ‫inches away if you want to take the American system here. 149 00:10:56,350 --> 00:10:59,230 ‫But that is basically what's going to happen. 150 00:10:59,230 --> 00:11:05,740 ‫Now, let's look at the chairs, because the chairs are going to have to go through a similar approach, 151 00:11:05,740 --> 00:11:11,200 ‫because we also want to make sure that a chair is destroyed, but the destruction of a chair will be 152 00:11:11,200 --> 00:11:12,010 ‫very different. 153 00:11:12,550 --> 00:11:15,730 ‫So here we will also add the interface. 154 00:11:16,000 --> 00:11:21,970 ‫So the I destroy all interface and of course we need to implement the destruction sound and that will 155 00:11:21,970 --> 00:11:28,630 ‫be a very different destruction because the chair will just fall apart and it will be shattering wood 156 00:11:28,630 --> 00:11:29,500 ‫that you hear. 157 00:11:29,500 --> 00:11:31,600 ‫So it will be a very different sound here. 158 00:11:32,320 --> 00:11:39,940 ‫And then of course, we want to define the destruction sound inside of our constructor as well. 159 00:11:40,210 --> 00:11:44,710 ‫So I'm going to say that the chair destruction sound should be played. 160 00:11:44,710 --> 00:11:45,880 ‫It will always be the same. 161 00:11:45,880 --> 00:11:50,290 ‫That's why I'm not adding it here in the declaration of the Chair. 162 00:11:50,290 --> 00:11:52,390 ‫So I'm keeping it simple here. 163 00:11:52,420 --> 00:11:55,780 ‫Of course, you could have different chairs that have different explosion sounds. 164 00:11:55,780 --> 00:12:00,280 ‫Then you would add it here at the top as a parameter for your constructor. 165 00:12:00,850 --> 00:12:04,150 ‫Okay, so now let's actually implement the destroy method. 166 00:12:04,150 --> 00:12:13,060 ‫And in this case, what will happen is we will destroy something and we will, first of all, destroy 167 00:12:13,060 --> 00:12:15,910 ‫the colored chair based on the color that the chair has. 168 00:12:15,910 --> 00:12:19,360 ‫We will write that, then we will play the destruction sound. 169 00:12:19,360 --> 00:12:22,750 ‫And then finally we are going to spawn chair parts. 170 00:12:23,320 --> 00:12:26,770 ‫So in our case we're just writing it onto the console. 171 00:12:26,770 --> 00:12:33,370 ‫But just imagine in a real game how you would do that, because the best way to destroy something in 172 00:12:33,370 --> 00:12:38,440 ‫a video game is not to actually do the physical thing where you do all of the destruction, which is 173 00:12:38,440 --> 00:12:40,810 ‫very difficult to build as especially if. 174 00:12:41,110 --> 00:12:43,870 ‫Don't have a big team that does all kinds of things. 175 00:12:44,200 --> 00:12:52,000 ‫Then you would basically just make a big explosion or destruction animation, and then you would spawn 176 00:12:52,000 --> 00:12:55,870 ‫the destroyed parts of the individual parts that lay around. 177 00:12:55,900 --> 00:13:00,100 ‫So you see here there is no chain reaction coming from this destroy method. 178 00:13:00,100 --> 00:13:05,290 ‫So the destroy method implementation for the chair is very different to the one from the vehicle, but 179 00:13:05,290 --> 00:13:11,350 ‫both of them inherit from the I destroy able interface and have to implement the destroy method and 180 00:13:11,350 --> 00:13:13,090 ‫they can do it their own way. 181 00:13:13,120 --> 00:13:19,570 ‫So basically interfaces allow us some sort of multi inheritance, even though it's not really multi 182 00:13:19,570 --> 00:13:20,470 ‫inheritance. 183 00:13:21,040 --> 00:13:21,530 ‫Okay. 184 00:13:21,550 --> 00:13:29,860 ‫So now let's go ahead and go to our program, CSS, and actually use our newly created classes because 185 00:13:29,860 --> 00:13:31,830 ‫well, otherwise it's boring, right? 186 00:13:31,840 --> 00:13:35,860 ‫So let's go ahead and create two chairs. 187 00:13:35,860 --> 00:13:40,510 ‫So we have an office chair which is going to be brown and plastic, and then we have a gaming chair 188 00:13:40,510 --> 00:13:41,890 ‫which will be red and wood. 189 00:13:42,220 --> 00:13:45,610 ‫And then let's also create a new car. 190 00:13:45,610 --> 00:13:50,410 ‫So this car will have a speed of 80 and it will be blue and it will be a damaged car. 191 00:13:50,410 --> 00:13:55,270 ‫And then we're going to add the two chairs nearby, this damaged car. 192 00:13:55,270 --> 00:14:00,400 ‫So we add them as destroyed wheels nearby to our damaged car. 193 00:14:00,400 --> 00:14:06,960 ‫So the office chair as well as the gaming chair will now be, if we look at it here as destroyed, it's 194 00:14:06,970 --> 00:14:10,090 ‫nearby because when creating a car, this list will be empty. 195 00:14:10,090 --> 00:14:16,120 ‫But then we can, of course, because it's a public list here, we can add items to it, which we do. 196 00:14:16,150 --> 00:14:18,700 ‫We add destroyed all items to it. 197 00:14:18,700 --> 00:14:24,160 ‫And why can we add chairs to our destroyed balls nearby? 198 00:14:24,280 --> 00:14:27,400 ‫Well, because a chair implements this interface. 199 00:14:28,060 --> 00:14:31,230 ‫That we called it tribal. 200 00:14:31,600 --> 00:14:38,560 ‫This means that a chair is now going to be accepted as an object of type I destroy. 201 00:14:39,190 --> 00:14:43,630 ‫Which means we can now add it as our disturbance nearby. 202 00:14:44,050 --> 00:14:47,440 ‫So now we can go ahead and destroy the car. 203 00:14:47,830 --> 00:14:53,530 ‫So let's just call the destroy method for our damaged car so the explosion can take part. 204 00:14:53,560 --> 00:14:57,530 ‫The explosion sound can start and all of the good stuff. 205 00:14:57,550 --> 00:14:58,750 ‫So let's run this. 206 00:14:58,750 --> 00:15:05,110 ‫And of course, this will be more of an adventure game and not so much a game where you see actual 3D 207 00:15:05,110 --> 00:15:06,220 ‫graphics or anything. 208 00:15:06,220 --> 00:15:10,470 ‫So we play the destruction sound, car explosion sound, we create the fire. 209 00:15:10,480 --> 00:15:12,660 ‫The brown chair was destroyed. 210 00:15:12,670 --> 00:15:16,630 ‫We are playing the destruction sound of the chair destruction sound amp three. 211 00:15:16,840 --> 00:15:21,130 ‫Then we are spawning the chair parts for our brown chair. 212 00:15:21,160 --> 00:15:23,110 ‫Then the red chair was destroyed. 213 00:15:23,110 --> 00:15:29,350 ‫We are playing the destruction sound of the chair destruction sound amp three and then we're spawning 214 00:15:29,350 --> 00:15:31,660 ‫chair parts for our red chair. 215 00:15:31,960 --> 00:15:33,760 ‫So you see, that's pretty much it. 216 00:15:33,760 --> 00:15:38,290 ‫So that's how you can create your own interfaces and how you can use them. 217 00:15:38,290 --> 00:15:44,860 ‫And I hope that you now understand what interfaces can do for you and the advantages of interfaces. 218 00:15:44,920 --> 00:15:52,270 ‫So an important note here by interfaces are used for communication between two similar or non similar 219 00:15:52,270 --> 00:15:57,400 ‫classes which do not care about the type of class implementing the interface. 220 00:15:57,400 --> 00:16:04,390 ‫Just like how our car communicated with the chair to call the destroy method all because they just implemented 221 00:16:04,390 --> 00:16:07,180 ‫the same interface as I earlier stated. 222 00:16:07,300 --> 00:16:14,260 ‫So while interfaces might seem hard to understand at first glance, they provide us with great perks. 223 00:16:14,500 --> 00:16:17,200 ‫Those perks are code readability. 224 00:16:17,200 --> 00:16:24,880 ‫So an interface constitutes a declaration about intentions, so it defines the capability of your class. 225 00:16:24,880 --> 00:16:31,900 ‫So what your class is capable of doing, if you implement the AI sortable, for example, you are clearly 226 00:16:31,900 --> 00:16:37,390 ‫stating that objects of your class can be sorted then code semantics. 227 00:16:37,390 --> 00:16:44,740 ‫By providing interfaces and implementing them, you're actively separating concepts and interface defines 228 00:16:44,740 --> 00:16:52,570 ‫a behavioral model, a definition of what an object can do and separating those concepts keeps the semantics 229 00:16:52,570 --> 00:16:54,250 ‫of your code a lot clearer. 230 00:16:54,670 --> 00:16:56,290 ‫Then you have the code. 231 00:16:56,290 --> 00:17:04,180 ‫Maintainability interfaces help reduce coupling and allow you to easily interchange implementations 232 00:17:04,180 --> 00:17:08,560 ‫for the same concept without the underlying code being affected. 233 00:17:08,590 --> 00:17:10,480 ‫And then we have design patterns. 234 00:17:10,480 --> 00:17:17,740 ‫It's the bigger picture of using contracts, abstraction and interfaces pivotal for object oriented 235 00:17:17,740 --> 00:17:22,360 ‫programming, so human understanding and complex system architecture. 236 00:17:22,360 --> 00:17:28,210 ‫So it's really basically just to understand it better as a human being and then multiple inheritance. 237 00:17:28,210 --> 00:17:33,880 ‫So interfaces can be our gateway to use multiple inheritance in C-sharp. 238 00:17:34,270 --> 00:17:38,980 ‫So suppose you write a library and want it to be modifiable by users. 239 00:17:38,980 --> 00:17:42,340 ‫You write interface and its class implementation. 240 00:17:42,460 --> 00:17:48,130 ‫Other developers who will use your library can still write their own implementation class, which may 241 00:17:48,130 --> 00:17:52,750 ‫use different technologies or algorithms that achieve the same result. 242 00:17:52,900 --> 00:17:58,330 ‫This is also why we meet so many interfaces in libraries we use, but rarely feel the need to write 243 00:17:58,330 --> 00:18:02,500 ‫our own interfaces because we don't write libraries ourselves. 244 00:18:02,530 --> 00:18:08,200 ‫On a final note, the important thing is to understand how interfaces are implemented at this point. 245 00:18:08,200 --> 00:18:14,230 ‫Of course, as we go through different technologies like WPF and ASP.NET and the C sharp master class, 246 00:18:14,230 --> 00:18:21,130 ‫we will start using interfaces more, which will help you understand them better in the future. 247 00:18:21,490 --> 00:18:21,850 ‫All right. 248 00:18:21,850 --> 00:18:23,590 ‫So thanks a lot for watching this video. 249 00:18:23,620 --> 00:18:24,850 ‫See you in the next one.