1
00:00:00,060 --> 00:00:04,620
We've seen a little bit of why Object Oriented Programming is really useful,

2
00:00:04,980 --> 00:00:09,510
but now let's take a look at how you would actually go about implementing Object

3
00:00:09,510 --> 00:00:10,530
Oriented Programming.

4
00:00:11,370 --> 00:00:15,240
So in the last lesson we talked of this example of the restaurant,

5
00:00:15,750 --> 00:00:18,600
where we hired three types of staff,

6
00:00:19,020 --> 00:00:24,020
and we had a manager who would then manage all of these three different types of

7
00:00:24,300 --> 00:00:25,830
staff. Now,

8
00:00:26,160 --> 00:00:31,160
the reason why Object Oriented Programming is called that is because it's trying

9
00:00:31,410 --> 00:00:34,350
to model a real world object.

10
00:00:34,770 --> 00:00:39,570
So let's say that we are creating a virtual restaurant. Well, in this case,

11
00:00:39,570 --> 00:00:43,320
we probably have to model a virtual chef, waiter,

12
00:00:43,350 --> 00:00:44,760
cleaner, and manager.

13
00:00:45,270 --> 00:00:50,270
So let's say that we were going to model a waiter. In order to model our waiter,

14
00:00:50,910 --> 00:00:55,910
there's probably two things we need to think about: what it has and what it does.

15
00:00:56,790 --> 00:01:00,540
In terms of what it has, well, it might have variables like,

16
00:01:00,570 --> 00:01:02,790
is it holding a plate, true or false?

17
00:01:03,360 --> 00:01:08,360
Or which tables is it responsible for? Maybe table 4, 5 and 6.

18
00:01:09,510 --> 00:01:11,940
Now it also has things that it does.

19
00:01:12,390 --> 00:01:17,390
Maybe they're able to take an order to the chef and maybe they also need to take

20
00:01:17,670 --> 00:01:22,470
payments and add money to the restaurant. So these two different things,

21
00:01:22,500 --> 00:01:25,650
what the waiter has and what the waiter does are

22
00:01:25,650 --> 00:01:30,650
the two most important things that make up an object: its attributes and its

23
00:01:32,520 --> 00:01:34,980
methods. By looking at the code,

24
00:01:35,010 --> 00:01:39,750
you can pretty much see that the attributes is basically a variable.

25
00:01:40,260 --> 00:01:45,260
An attribute is just a fancy word for a variable that's associated with a

26
00:01:46,410 --> 00:01:48,660
modeled object like our waiter here.

27
00:01:49,260 --> 00:01:52,500
Because it's not just a free floating bit of a variable, right?

28
00:01:52,500 --> 00:01:54,690
It's not just somewhere in our main.py.

29
00:01:55,050 --> 00:01:59,130
It's actually a variable that's attached to a particular object.

30
00:01:59,400 --> 00:02:02,130
It's the waiter's tables responsible.

31
00:02:02,850 --> 00:02:05,970
Now the method goes along the same vein. These,

32
00:02:06,060 --> 00:02:08,520
as you can clearly see, are just functions

33
00:02:09,090 --> 00:02:14,090
but we call it a method because it's a function that a particular modeled

34
00:02:14,730 --> 00:02:16,500
object can do.

35
00:02:17,160 --> 00:02:22,160
We need a waiter object to take the order and we need a waiter object to take

36
00:02:22,260 --> 00:02:25,950
payment. Again, these are not just free-floating functions.

37
00:02:26,520 --> 00:02:31,520
Now, there's a lot of new words that are part of Object Oriented Programming and

38
00:02:31,740 --> 00:02:35,160
programming in general, we're going to see them again and again,

39
00:02:35,220 --> 00:02:38,160
and eventually it's going to become a word that's going to be in your

40
00:02:38,160 --> 00:02:42,720
dictionary. But for now, just remember that in Object Oriented

41
00:02:42,720 --> 00:02:43,350
Programming,

42
00:02:43,350 --> 00:02:48,350
we're trying to model real-life objects and those objects have things

43
00:02:49,590 --> 00:02:51,720
and they also can do things.

44
00:02:52,110 --> 00:02:54,780
The things that they have are their attributes

45
00:02:55,200 --> 00:02:59,980
and these are usually modeled with variables, and the things that they can do

46
00:03:00,280 --> 00:03:03,400
are called methods and they are modeled by functions.

47
00:03:04,060 --> 00:03:09,060
So essentially, an object is just a way of combining some piece of data and some

48
00:03:10,810 --> 00:03:14,170
functionality altogether in the same thing.

49
00:03:15,370 --> 00:03:20,370
But we can actually have multiple objects generated from the same type.

50
00:03:21,190 --> 00:03:24,940
So when we've modeled a particular job in our virtual restaurant

51
00:03:25,030 --> 00:03:26,800
like the waiter's job,

52
00:03:27,490 --> 00:03:31,090
and we figured out what are the things that the waiter have and what are the

53
00:03:31,090 --> 00:03:33,220
things that it can do, well,

54
00:03:33,220 --> 00:03:38,220
we can actually generate multiple versions of the same object. So we could have

55
00:03:38,950 --> 00:03:43,270
Henry who's a waiter and we can also have Betty who's a waiter,

56
00:03:43,840 --> 00:03:48,460
and we can generate as many of these as we want from the same blueprint.

57
00:03:48,970 --> 00:03:53,970
And in OOP we call this blueprint, or this type, a class.

58
00:03:56,170 --> 00:04:01,170
And we call these individual objects that are generated from the blueprint

59
00:04:01,480 --> 00:04:02,320
an object.

60
00:04:03,070 --> 00:04:08,070
So now let's take a look at how you use these class blueprints to create an actual

61
00:04:08,380 --> 00:04:08,950
object.

