1
00:00:00,000 --> 00:00:01,000
Hello guys.

2
00:00:01,000 --> 00:00:04,000
So we are going to continue the discussion with respect to Python.

3
00:00:04,000 --> 00:00:09,000
And in this video we are going to discuss about a new topic which is called as abstraction, which is

4
00:00:09,000 --> 00:00:13,000
one of the most important core pillar in oops concept.

5
00:00:13,000 --> 00:00:15,000
Now what exactly is abstraction?

6
00:00:15,000 --> 00:00:21,000
Abstraction is the concept of hiding the complex implementation detail and showing only the necessary

7
00:00:21,000 --> 00:00:23,000
feature of an object.

8
00:00:23,000 --> 00:00:26,000
This helps in reducing programming complexity and effort.

9
00:00:26,000 --> 00:00:33,000
Let me talk about some good examples so that you will be able to understand what does exactly abstraction

10
00:00:33,000 --> 00:00:34,000
mean.

11
00:00:34,000 --> 00:00:34,000
Okay.

12
00:00:35,000 --> 00:00:38,000
Uh, let's consider one thing very simple thing, okay.

13
00:00:38,000 --> 00:00:42,000
With respect to abstraction, if I just want to give you a real world example, I hope everybody uses

14
00:00:42,000 --> 00:00:43,000
a washing machine.

15
00:00:43,000 --> 00:00:43,000
Right.

16
00:00:43,000 --> 00:00:50,000
And if you are using a washing machine in a washing machine, you will be having all the options to

17
00:00:50,000 --> 00:00:51,000
start the washing machine.

18
00:00:51,000 --> 00:00:53,000
How much for what timer?

19
00:00:53,000 --> 00:00:55,000
You have to probably run the washing machine.

20
00:00:55,000 --> 00:00:57,000
You have an option to set the timer.

21
00:00:57,000 --> 00:01:01,000
Along with that, you will be seeing that you'll be having a dryer part.

22
00:01:01,000 --> 00:01:04,000
You know where you'll be able to dry the clothes itself, right?

23
00:01:04,000 --> 00:01:09,000
And just with the help of a click of a button, you will be able to do that specific operation.

24
00:01:09,000 --> 00:01:16,000
Now that buttons that is visible on that washing machine is the thing, or is the feature of that particular

25
00:01:16,000 --> 00:01:20,000
object that is visible to you remaining all the complex implementation?

26
00:01:20,000 --> 00:01:25,000
How how the washing probably takes place, how that particular as soon as you probably click start,

27
00:01:25,000 --> 00:01:31,000
what is the internal process that is going to happen that all complex implementation is completely hidden,

28
00:01:31,000 --> 00:01:32,000
right.

29
00:01:32,000 --> 00:01:36,000
And this is what can be taken as a real world example with respect to abstraction.

30
00:01:36,000 --> 00:01:42,000
Not only that, you can also consider an example with respect to mobile phones, AC remote, your laptop,

31
00:01:42,000 --> 00:01:43,000
your desktop.

32
00:01:43,000 --> 00:01:45,000
You know you'll be able to see buttons are there.

33
00:01:45,000 --> 00:01:45,000
Okay.

34
00:01:45,000 --> 00:01:50,000
You'll be able to see, hey, if I go ahead and probably, uh, touch go if I go ahead and click on

35
00:01:50,000 --> 00:01:52,000
shut down automatically how the system is getting shut down.

36
00:01:52,000 --> 00:02:00,000
If I open a specific application, how that particular application processes process is basically allocated

37
00:02:00,000 --> 00:02:04,000
in the processor, in the Ram, how much memory is basically getting allocated.

38
00:02:04,000 --> 00:02:08,000
So everything is happening in the back end over there, and there are some kind of complex implementation

39
00:02:08,000 --> 00:02:14,000
that is happening in the back end, and that is completely hidden right now in order to make your understand

40
00:02:14,000 --> 00:02:15,000
about abstraction.

41
00:02:15,000 --> 00:02:18,000
Uh, so let me just go and talk with respect to code.

42
00:02:18,000 --> 00:02:23,000
So here I will go ahead and say, hey, from ABC, I'm going to import, uh, ABC.

43
00:02:23,000 --> 00:02:27,000
So this ABC is nothing, but it is for the abstraction.

44
00:02:27,000 --> 00:02:32,000
Uh, it is just for abstract class, you know, which we specifically use.

45
00:02:32,000 --> 00:02:37,000
And let's say if I want to define an abstract method, okay, I will go ahead and define an abstract

46
00:02:37,000 --> 00:02:37,000
method.

47
00:02:37,000 --> 00:02:41,000
I'll talk about what why this method is very much important and all okay.

48
00:02:41,000 --> 00:02:45,000
So first of all let us go ahead and define my abstract class.

49
00:02:45,000 --> 00:02:48,000
Now what is this abstract class?

50
00:02:48,000 --> 00:02:53,000
Let's say that I go ahead and define my vehicle class over here okay.

51
00:02:53,000 --> 00:02:59,000
Now when I'm defining my vehicle class here, I will be considering it as ABC and always remember the

52
00:02:59,000 --> 00:03:04,000
difference between a normal class and an abstract class is that here I will be inheriting this A, B,

53
00:03:04,000 --> 00:03:05,000
c class, right?

54
00:03:05,000 --> 00:03:08,000
And which is nothing, but it is for the abstract class itself.

55
00:03:08,000 --> 00:03:08,000
Right?

56
00:03:09,000 --> 00:03:11,000
Or you can also say abstract base class.

57
00:03:11,000 --> 00:03:13,000
Okay, this is nothing but abstract base class.

58
00:03:13,000 --> 00:03:15,000
Here you can actually see we are inheriting them.

59
00:03:15,000 --> 00:03:16,000
Okay.

60
00:03:16,000 --> 00:03:19,000
Now let's say inside this particular class I have some definition.

61
00:03:19,000 --> 00:03:23,000
And the definition can be anything over here.

62
00:03:23,000 --> 00:03:23,000
Right.

63
00:03:23,000 --> 00:03:30,000
Let's say that I will go ahead and write, uh, um, uh, with respect to vehicle, I will say, hey,

64
00:03:30,000 --> 00:03:33,000
I have a function which is called as drive, okay.

65
00:03:33,000 --> 00:03:43,000
And I will go ahead and print and write some information like, uh, the car, the vehicle, the vehicle

66
00:03:43,000 --> 00:03:47,000
is used for driving.

67
00:03:47,000 --> 00:03:48,000
Okay.

68
00:03:49,000 --> 00:03:50,000
Something like this.

69
00:03:50,000 --> 00:03:52,000
I'm just writing some kind of examples over here.

70
00:03:52,000 --> 00:03:54,000
Now, this is a normal method.

71
00:03:54,000 --> 00:03:57,000
Now let me go ahead and define an abstract method.

72
00:03:57,000 --> 00:04:04,000
Usually when we go ahead and define an abstract method this will be a complete empty function okay.

73
00:04:05,000 --> 00:04:11,000
And the best thing about abstract is that it is created in such a purpose that whenever a child class

74
00:04:11,000 --> 00:04:17,000
inherits this vehicle base class, it says that hey, I am giving you a functionality with respect to

75
00:04:17,000 --> 00:04:18,000
drive, okay?

76
00:04:18,000 --> 00:04:24,000
And I am giving you one abstract method which you can do the implementation with your own way.

77
00:04:24,000 --> 00:04:26,000
Okay, that is what it is basically driven.

78
00:04:26,000 --> 00:04:32,000
So this abstract method is just like giving you the necessary feature of an object.

79
00:04:32,000 --> 00:04:34,000
And it is just hiding the complex implementation detail.

80
00:04:34,000 --> 00:04:35,000
Right.

81
00:04:35,000 --> 00:04:38,000
So here we are just trying to provide you a way.

82
00:04:38,000 --> 00:04:41,000
So let me just go ahead and again repeat this okay.

83
00:04:41,000 --> 00:04:41,000
No.

84
00:04:41,000 --> 00:04:44,000
Let's consider that I'm going to probably write an abstract method over here.

85
00:04:44,000 --> 00:04:48,000
Now in order to define an abstract method we'll go ahead and write definition start engine.

86
00:04:48,000 --> 00:04:50,000
Let's say this is my start engine.

87
00:04:50,000 --> 00:04:52,000
And I will go ahead and write self over here.

88
00:04:52,000 --> 00:04:55,000
And let's say that this is my empty class okay.

89
00:04:55,000 --> 00:05:00,000
Now in abstraction what happens is that as I said, this is my abstract base class.

90
00:05:00,000 --> 00:05:03,000
And this is how we create an abstract method which will be completely empty.

91
00:05:03,000 --> 00:05:11,000
Now, if I probably go ahead and create my child class and let's say this child class is inheriting

92
00:05:11,000 --> 00:05:12,000
the vehicle class.

93
00:05:12,000 --> 00:05:19,000
Now, before inheriting always let's say that if I am inheriting this abstract base class, which is

94
00:05:19,000 --> 00:05:24,000
nothing but vehicle, which is also called as an abstract class, here it says that you can inherit

95
00:05:24,000 --> 00:05:26,000
a you, uh, this This car class.

96
00:05:26,000 --> 00:05:28,000
Class can basically inherit the vehicle class.

97
00:05:28,000 --> 00:05:30,000
But there will be one condition.

98
00:05:30,000 --> 00:05:32,000
You will be able to use this particular method.

99
00:05:32,000 --> 00:05:37,000
But to use this method we have to write our own definition.

100
00:05:37,000 --> 00:05:42,000
Write that the car will basically be writing its own specific definition over here.

101
00:05:42,000 --> 00:05:42,000
Okay.

102
00:05:42,000 --> 00:05:48,000
So in order to show you over here what I will do, I will just go ahead and write definition start underscore

103
00:05:48,000 --> 00:05:49,000
engine okay.

104
00:05:49,000 --> 00:05:51,000
Start underscore engine.

105
00:05:51,000 --> 00:05:55,000
And here we will just go ahead and write the self keyword.

106
00:05:55,000 --> 00:06:01,000
And let's say here we go ahead and write car engine started okay.

107
00:06:02,000 --> 00:06:04,000
So car engine started.

108
00:06:04,000 --> 00:06:10,000
So here you can actually see that I am actually able to write the code right now.

109
00:06:10,000 --> 00:06:11,000
What I am actually going to do.

110
00:06:11,000 --> 00:06:14,000
See now I will just go ahead and initialize something.

111
00:06:14,000 --> 00:06:18,000
You know I'll, I'll, I'll, I'll, uh I'll, I'll, I'll, I'll create a function.

112
00:06:18,000 --> 00:06:22,000
Let me go ahead and create a function saying that operate vehicle.

113
00:06:22,000 --> 00:06:22,000
Okay.

114
00:06:22,000 --> 00:06:24,000
So this will be my function.

115
00:06:24,000 --> 00:06:29,000
And this will basically, uh, demonstrate our entire process of abstraction.

116
00:06:29,000 --> 00:06:32,000
So I will go ahead and just operate vehicle.

117
00:06:32,000 --> 00:06:35,000
And here I'm going to probably write vehicle okay.

118
00:06:36,000 --> 00:06:42,000
Vehicle dot start underscore engine start underscore engine.

119
00:06:42,000 --> 00:06:43,000
Uh.

120
00:06:44,000 --> 00:06:48,000
So vehicle vehicle vehicle spelling needs to be correct.

121
00:06:48,000 --> 00:06:49,000
Start underscore engine.

122
00:06:49,000 --> 00:06:51,000
So here is my start underscore engine.

123
00:06:51,000 --> 00:06:54,000
Now let me define this.

124
00:06:54,000 --> 00:06:57,000
This function is created and it is outside the class okay.

125
00:06:57,000 --> 00:06:59,000
Now let me just go ahead and write car is equal to car.

126
00:07:00,000 --> 00:07:05,000
And now let me just go ahead and call this operate vehicle with respect to car.

127
00:07:06,000 --> 00:07:10,000
So here you will be able to see that what is basically happened here.

128
00:07:10,000 --> 00:07:12,000
This start engine is getting displayed.

129
00:07:12,000 --> 00:07:16,000
Now you need to understand where does abstraction come into mind.

130
00:07:16,000 --> 00:07:22,000
Right here we are just saying that hey there is one functionality okay?

131
00:07:22,000 --> 00:07:25,000
There is one functionality which is available for you.

132
00:07:25,000 --> 00:07:25,000
Right?

133
00:07:25,000 --> 00:07:29,000
And this is basically defined in the form of an abstract method.

134
00:07:29,000 --> 00:07:33,000
And this abstract method, if it is present, if we really need to create an abstract class, we have

135
00:07:33,000 --> 00:07:38,000
to inherit this ABC, right ABC library that we have imported over here.

136
00:07:38,000 --> 00:07:43,000
Now, if any child class wants to inherit this particular abstract base class, we have to make sure

137
00:07:43,000 --> 00:07:46,000
that we will be able to use this particular function.

138
00:07:46,000 --> 00:07:51,000
But along with that, we have to make sure that you have to go ahead and implement this particular function

139
00:07:51,000 --> 00:07:52,000
with your own way.

140
00:07:52,000 --> 00:07:55,000
And that is what we have actually done over here, right?

141
00:07:55,000 --> 00:08:01,000
If I go ahead and also write over here something like this vehicle, let's say if I go ahead and write

142
00:08:01,000 --> 00:08:09,000
vehicle vehicle dot uh along with this dot drive.

143
00:08:09,000 --> 00:08:11,000
So drive will also be able to access it.

144
00:08:11,000 --> 00:08:12,000
Right.

145
00:08:12,000 --> 00:08:13,000
We'll be able to access it.

146
00:08:13,000 --> 00:08:16,000
Now if I go ahead and execute it you can see the vehicle is used for driving.

147
00:08:16,000 --> 00:08:19,000
So the derived class is also able to use this.

148
00:08:19,000 --> 00:08:24,000
But with respect to this abstract method, which is where the abstraction is basically getting applied,

149
00:08:24,000 --> 00:08:28,000
where we are just showing the features of this particular objects.

150
00:08:28,000 --> 00:08:28,000
Right?

151
00:08:28,000 --> 00:08:34,000
We are just showing this particular method, but the complex implementation can be overridden by all

152
00:08:34,000 --> 00:08:39,000
the, uh, derived class that is specifically using them, and that what is basically done over here.

153
00:08:39,000 --> 00:08:39,000
Right.

154
00:08:39,000 --> 00:08:45,000
So this actually gives an example or it makes you understand about the abstraction, uh method over

155
00:08:45,000 --> 00:08:50,000
here with respect to the Python and how you can actually create your abstract class, how you can basically

156
00:08:50,000 --> 00:08:54,000
create an abstract method and how abstract abstraction is basically implemented over here.

157
00:08:54,000 --> 00:08:59,000
But in short, if I really want to discuss abstraction is the concept of hiding the complex implementation

158
00:08:59,000 --> 00:09:02,000
detail and showing only the necessary features of an object.

159
00:09:02,000 --> 00:09:03,000
Right?

160
00:09:03,000 --> 00:09:05,000
So yes, this was it from my side.

161
00:09:05,000 --> 00:09:06,000
I hope you liked this particular video.

162
00:09:06,000 --> 00:09:08,000
I will see you all in the next video.

163
00:09:08,000 --> 00:09:08,000
Thank you.

