1 00:00:01,050 --> 00:00:01,830 ‫Welcome back. 2 00:00:01,860 --> 00:00:05,640 ‫In this video, it's all about inheritance and in this chapter in general. 3 00:00:05,640 --> 00:00:10,680 ‫And we are going to have a look at the definition first and then we'll see an example. 4 00:00:10,680 --> 00:00:14,570 ‫And in the next videos we're going to get into demo. 5 00:00:14,580 --> 00:00:21,120 ‫So first of all, a definition inheritance allows us to define a class in terms of another class, which 6 00:00:21,120 --> 00:00:24,480 ‫makes it easier to create and maintain an application. 7 00:00:24,480 --> 00:00:31,050 ‫This also provides an opportunity to reuse the code functionality and speed up implementation time. 8 00:00:31,050 --> 00:00:37,800 ‫So that means that we can create classes and we've seen that already and we can take those classes and 9 00:00:37,800 --> 00:00:45,000 ‫their functionality and methods and then reuse that and simply add on top of that without adjusting 10 00:00:45,000 --> 00:00:52,560 ‫the class itself so we can inherit from that class and use additional functionality and additional properties 11 00:00:52,560 --> 00:00:53,820 ‫and those kind of things. 12 00:00:53,820 --> 00:01:01,380 ‫And that allows us to have a much more maintainable code that is easier to maintain in the future. 13 00:01:01,380 --> 00:01:07,590 ‫And it really makes sense as soon as the programs get or the applications get a lot more complex. 14 00:01:07,590 --> 00:01:12,540 ‫And it also speeds up implementation time because you don't have to copy and paste a lot of code or 15 00:01:12,540 --> 00:01:14,100 ‫write code once again and again. 16 00:01:14,100 --> 00:01:20,070 ‫But you can simply take that from the other class or inherit the other class and use its functionality. 17 00:01:20,070 --> 00:01:26,190 ‫And that's something that we can not only do with classes that we create ourself, but we can use the 18 00:01:26,190 --> 00:01:29,010 ‫ones that are in the libraries that we use. 19 00:01:29,010 --> 00:01:32,460 ‫So we can simply import libraries and then use those. 20 00:01:32,460 --> 00:01:33,390 ‫And that's amazing. 21 00:01:33,540 --> 00:01:37,320 ‫So let's have a look at inheritance, for example, a car. 22 00:01:37,320 --> 00:01:44,970 ‫So a car is the base class and that can be inherited from so there is a deriving class, for example, 23 00:01:44,970 --> 00:01:52,440 ‫race car and street car and, and here the car has some properties and some methods and they are true 24 00:01:52,440 --> 00:01:53,250 ‫for every car. 25 00:01:53,250 --> 00:01:59,070 ‫So every car has horsepower, every car has windows, every car is an amount of wheels. 26 00:01:59,070 --> 00:02:01,470 ‫And at the same time they also have a method. 27 00:02:01,470 --> 00:02:06,300 ‫So every car should drive and I guess every car should be able to honk. 28 00:02:06,300 --> 00:02:12,030 ‫And those are properties and methods which are true for all cars. 29 00:02:12,030 --> 00:02:14,910 ‫So a race car has those things as well. 30 00:02:14,910 --> 00:02:20,490 ‫But on top of that, it has a property, for example, it has a turbo which allows it to drive faster. 31 00:02:20,490 --> 00:02:27,510 ‫Then it has the method racing, so it allows them to race in general on the racing pit, maybe it's 32 00:02:27,510 --> 00:02:29,430 ‫not allowed to drive on a street. 33 00:02:29,430 --> 00:02:32,430 ‫On the other hand, a street car may do that. 34 00:02:32,430 --> 00:02:34,110 ‫So it has the method street, right. 35 00:02:34,110 --> 00:02:36,000 ‫And the property comfort. 36 00:02:36,000 --> 00:02:42,150 ‫Well, in this example, the comfort is limited maybe, but generally that's how you could see it. 37 00:02:42,150 --> 00:02:43,860 ‫And you can extend that by a lot. 38 00:02:43,860 --> 00:02:49,080 ‫And it's not just cars and and in the next slide, employees, it's pretty much everything. 39 00:02:49,230 --> 00:02:54,420 ‫So you can see that on phones, a phone can be inherited. 40 00:02:54,420 --> 00:02:58,200 ‫And for example, a smartphone is a phone. 41 00:02:58,200 --> 00:03:03,390 ‫So it has the capabilities of a phone, but at the same time it has some additional capabilities. 42 00:03:03,390 --> 00:03:06,360 ‫But now let's have a look at employees. 43 00:03:06,360 --> 00:03:11,640 ‫So another example, we have an employee which is the base class, and it has properties such as salary 44 00:03:11,640 --> 00:03:13,440 ‫work hours and plenty more. 45 00:03:13,440 --> 00:03:18,330 ‫And then methods the methods are do the job, get to work, get paid. 46 00:03:18,330 --> 00:03:19,980 ‫So that's pretty much it. 47 00:03:20,130 --> 00:03:22,500 ‫And then there's a lot more of course. 48 00:03:22,500 --> 00:03:25,920 ‫And then we have deriving classes, for example, the designer. 49 00:03:25,950 --> 00:03:33,660 ‫A designer has the property of years of design experience, then level of creativity and a lot more. 50 00:03:33,660 --> 00:03:37,140 ‫And the methods, for example, design and draw stuff. 51 00:03:37,260 --> 00:03:43,800 ‫The engineer, on the other hand, is also deriving class and has properties such as years of a programming 52 00:03:43,800 --> 00:03:49,620 ‫experience or a level of sarcasm and then methods, design and program. 53 00:03:49,620 --> 00:03:55,560 ‫And you see here design is true for the designer and the engineer, but even though they are the same 54 00:03:55,560 --> 00:03:59,220 ‫in both cases, they are not true for every employee. 55 00:03:59,220 --> 00:04:02,190 ‫So not every employee needs to design something. 56 00:04:02,190 --> 00:04:08,340 ‫That's why they even though they are pretty much copying methods from the two, they could still be 57 00:04:08,340 --> 00:04:08,700 ‫different. 58 00:04:08,700 --> 00:04:13,110 ‫So a design method in engineer could be different to the design method in the designer. 59 00:04:13,350 --> 00:04:20,250 ‫But the employee itself doesn't need to design and only those driving classes need those methods. 60 00:04:20,370 --> 00:04:24,660 ‫So let's just some examples on a theoretical level. 61 00:04:24,660 --> 00:04:28,920 ‫We will look into that in a demo in the next video. 62 00:04:28,920 --> 00:04:31,230 ‫And not just that, we will have plenty of examples. 63 00:04:31,230 --> 00:04:35,280 ‫So no worries if that's not enough for you to grasp the whole concept. 64 00:04:35,280 --> 00:04:38,490 ‫We will look into all the different aspects of inheritance. 65 00:04:38,760 --> 00:04:39,060 ‫Yeah. 66 00:04:39,060 --> 00:04:41,640 ‫So let's go to the next video and get started.