1
00:00:04,100 --> 00:00:06,920
Hi, welcome to this new lesson.

2
00:00:06,920 --> 00:00:08,620
We're going to start Week 4,

3
00:00:08,620 --> 00:00:10,620
where we're going
to be discovering

4
00:00:10,620 --> 00:00:13,260
the power of object-oriented
programming.

5
00:00:13,260 --> 00:00:16,900
Object-oriented programming
is a really exciting topic

6
00:00:16,900 --> 00:00:19,720
that I was really looking
forward to reach because

7
00:00:19,720 --> 00:00:21,940
it really opens up for you

8
00:00:21,940 --> 00:00:25,740
a whole range of techniques
and methodologies that you

9
00:00:25,740 --> 00:00:30,040
can use and really start
expanding much more the power of

10
00:00:30,040 --> 00:00:32,360
programming in Python
and other languages

11
00:00:32,360 --> 00:00:35,100
that use object-oriented
programming as a paradigm,

12
00:00:35,100 --> 00:00:40,300
really benefit from the
increasing reusability

13
00:00:40,300 --> 00:00:42,220
and possibilities with
code that is written

14
00:00:42,220 --> 00:00:44,250
in such a way.

15
00:00:44,250 --> 00:00:45,330
Let's learn a little bit of

16
00:00:45,330 --> 00:00:48,280
what object-oriented
programming means.

17
00:00:48,280 --> 00:00:50,660
The principle of
object-oriented programming

18
00:00:50,660 --> 00:00:52,220
is the idea that
you can actually

19
00:00:52,220 --> 00:00:54,800
construct an object through

20
00:00:54,800 --> 00:00:56,320
the process of creating a class.

21
00:00:56,320 --> 00:00:59,865
A class is an outline
of an object.

22
00:00:59,865 --> 00:01:02,800
As we have it here, let's
look at this diagram.

23
00:01:02,800 --> 00:01:06,040
We have the idea of creating
an object like a dog,

24
00:01:06,040 --> 00:01:09,080
and we will have
certain attributes,

25
00:01:09,080 --> 00:01:13,230
certain characteristics
that this dog will contain.

26
00:01:13,230 --> 00:01:15,090
We have the idea of a name.

27
00:01:15,090 --> 00:01:19,350
Maybe the species of
the dog, the age.

28
00:01:19,350 --> 00:01:22,940
Then there's also a
series of action,

29
00:01:22,940 --> 00:01:24,880
a series of maybe functions

30
00:01:24,880 --> 00:01:28,110
that this dog as an
object will perform,

31
00:01:28,110 --> 00:01:30,615
something like
barking or fetching.

32
00:01:30,615 --> 00:01:36,720
If we look behind the
hood of this object,

33
00:01:36,720 --> 00:01:39,000
we have a structure to it.

34
00:01:39,000 --> 00:01:41,800
We have a class
name that defines

35
00:01:41,800 --> 00:01:45,825
what is this class.
We have some data.

36
00:01:45,825 --> 00:01:48,740
As we can see from the outline,

37
00:01:48,740 --> 00:01:52,140
some data that is contained
within this object,

38
00:01:52,140 --> 00:01:54,475
and then we have a
series of functions.

39
00:01:54,475 --> 00:01:57,365
All of this packaged together

40
00:01:57,365 --> 00:01:59,840
is what we would
actually call a class,

41
00:01:59,840 --> 00:02:02,645
that would be, again, an
outline of an object.

42
00:02:02,645 --> 00:02:05,300
Let's understand how,
before we actually write,

43
00:02:05,300 --> 00:02:06,920
the code and
understand the syntax

44
00:02:06,920 --> 00:02:08,890
for how to write a class,

45
00:02:08,890 --> 00:02:12,560
how we can actually
make use of this class.

46
00:02:12,560 --> 00:02:15,410
If we have the class dog,

47
00:02:15,410 --> 00:02:17,370
that means that we could have

48
00:02:17,370 --> 00:02:21,155
perhaps maybe many
instances of this class.

49
00:02:21,155 --> 00:02:23,150
We can see on the
right, what we are

50
00:02:23,150 --> 00:02:25,610
calling an instance
of a class is in

51
00:02:25,610 --> 00:02:27,950
fact a construction and

52
00:02:27,950 --> 00:02:30,510
an entity that will
operate within our script,

53
00:02:30,510 --> 00:02:33,705
in our simulation,
in processing.

54
00:02:33,705 --> 00:02:36,050
In the case of the instance,

55
00:02:36,050 --> 00:02:37,750
the data that we're calling

56
00:02:37,750 --> 00:02:39,970
name would actually
have a specific name.

57
00:02:39,970 --> 00:02:42,860
You could imagine, I
don't know, Max dog.

58
00:02:42,860 --> 00:02:47,195
Then the species will be
a specific kind of dog,

59
00:02:47,195 --> 00:02:49,445
and then also a particular age.

60
00:02:49,445 --> 00:02:52,035
That doesn't mean that
all dogs have that age,

61
00:02:52,035 --> 00:02:53,750
except in this
particular instance

62
00:02:53,750 --> 00:02:55,630
of the dog has that age.

63
00:02:55,630 --> 00:02:57,750
Also, it might not be
barking all the time.

64
00:02:57,750 --> 00:02:59,010
It might be sometimes barking,

65
00:02:59,010 --> 00:03:02,925
so the function bark might be
executed at certain times.

66
00:03:02,925 --> 00:03:05,040
We can have, as I mentioned,

67
00:03:05,040 --> 00:03:07,240
multiple instances of a class.

68
00:03:07,240 --> 00:03:10,400
This is the power of the
reusability of a piece of code

69
00:03:10,400 --> 00:03:14,500
that we write as a template
for a type of object,

70
00:03:14,500 --> 00:03:18,420
an object that we will
actually be able to reuse.

71
00:03:18,420 --> 00:03:21,760
But each time we
construct a new object,

72
00:03:21,760 --> 00:03:23,200
in this case, a new dog,

73
00:03:23,200 --> 00:03:25,760
that new dog might have
different pieces of data,

74
00:03:25,760 --> 00:03:27,100
might have different names as

75
00:03:27,100 --> 00:03:28,660
we have them in the real world,

76
00:03:28,660 --> 00:03:30,365
different age, and so on,

77
00:03:30,365 --> 00:03:32,885
and they might invoke
their barking function and

78
00:03:32,885 --> 00:03:37,345
their fetching function
at different times.

79
00:03:37,345 --> 00:03:41,110
Classes are an
incredibly useful tool

80
00:03:41,110 --> 00:03:44,170
to think of modular
forms of programming,

81
00:03:44,170 --> 00:03:45,770
scalable forms of programming,

82
00:03:45,770 --> 00:03:48,730
where you could actually
write this code and reuse it.

83
00:03:48,730 --> 00:03:50,090
You could even write it

84
00:03:50,090 --> 00:03:51,410
in such a way that
it's completely

85
00:03:51,410 --> 00:03:54,780
self-packaged and you
can move it around.

86
00:03:54,780 --> 00:03:58,970
It really starts opening up
what we can actually do with

87
00:03:58,970 --> 00:04:02,770
programming and really scaling
our programming skills.

88
00:04:02,770 --> 00:04:05,850
I'm going to move forward to
just show you the syntax of

89
00:04:05,850 --> 00:04:07,350
a class and we'll start writing

90
00:04:07,350 --> 00:04:10,130
classes together in
the next few lessons.