1
00:00:05,240 --> 00:00:08,480
Hi, welcome to this new lesson.

2
00:00:08,480 --> 00:00:10,180
We're going to start
talking a little bit

3
00:00:10,180 --> 00:00:12,700
about modularity in programming.

4
00:00:12,700 --> 00:00:14,860
If you imagine that you could

5
00:00:14,860 --> 00:00:17,280
actually write a complex
piece of software,

6
00:00:17,280 --> 00:00:18,860
just the way we've been writing

7
00:00:18,860 --> 00:00:21,400
variables and some
arithmetic operators.

8
00:00:21,400 --> 00:00:23,760
You'll probably soon
realize this is

9
00:00:23,760 --> 00:00:27,060
not a very productive
way of working.

10
00:00:27,060 --> 00:00:29,860
For that actually
in programming,

11
00:00:29,860 --> 00:00:32,340
we introduced the
notion of modularity,

12
00:00:32,340 --> 00:00:36,205
which will take us into
the notion of functions.

13
00:00:36,205 --> 00:00:39,880
If we think of a program
or a piece of software,

14
00:00:39,880 --> 00:00:43,860
it's worth thinking of
it in different modules.

15
00:00:43,860 --> 00:00:45,740
Modules are very arbitrary,

16
00:00:45,740 --> 00:00:47,900
something that you would start

17
00:00:47,900 --> 00:00:49,960
conceiving of as you
kind of know more,

18
00:00:49,960 --> 00:00:51,200
and you might think, well,

19
00:00:51,200 --> 00:00:53,800
maybe this is the part of
the software that deals with

20
00:00:53,800 --> 00:00:56,820
reading and writing
information into a database.

21
00:00:56,820 --> 00:00:59,440
Maybe another part of the
program has to do with

22
00:00:59,440 --> 00:01:03,475
the graphic representation
of the data within a screen.

23
00:01:03,475 --> 00:01:06,320
Like that, you might
have a series of

24
00:01:06,320 --> 00:01:09,510
modules which are
higher order concepts,

25
00:01:09,510 --> 00:01:11,440
and those are arbitrary,

26
00:01:11,440 --> 00:01:13,100
they're your design to

27
00:01:13,100 --> 00:01:15,760
really start conceiving
of those modules.

28
00:01:15,760 --> 00:01:18,855
Later in a more pragmatic form,

29
00:01:18,855 --> 00:01:21,130
those modules will be further

30
00:01:21,130 --> 00:01:24,450
broken into objects
or functions.

31
00:01:24,450 --> 00:01:26,610
We will cover objects,

32
00:01:26,610 --> 00:01:32,150
which is a big topic in second
specialization in number

33
00:01:32,150 --> 00:01:34,310
2 because it's like

34
00:01:34,310 --> 00:01:36,270
a very important concept

35
00:01:36,270 --> 00:01:38,050
that is a little
bit more advanced.

36
00:01:38,050 --> 00:01:39,970
But for now, let's
talk about functions.

37
00:01:39,970 --> 00:01:42,210
Functions, it is a
very good way to

38
00:01:42,210 --> 00:01:45,400
write a piece of code
that you can reuse.

39
00:01:45,400 --> 00:01:47,650
Imagine that you're creating

40
00:01:47,650 --> 00:01:51,105
your own summation calculation.

41
00:01:51,105 --> 00:01:52,490
The way you would add

42
00:01:52,490 --> 00:01:54,625
two numbers on
addition calculation.

43
00:01:54,625 --> 00:01:58,000
Well, you can specify,
maybe I want to print,

44
00:01:58,000 --> 00:01:59,500
while I do that, I want to print

45
00:01:59,500 --> 00:02:01,960
the results in a
specific format.

46
00:02:01,960 --> 00:02:04,300
Or maybe I would like
to do a series of

47
00:02:04,300 --> 00:02:08,440
other operations or validate
the data as it comes in.

48
00:02:08,440 --> 00:02:11,360
You can package all that into
a function so that every

49
00:02:11,360 --> 00:02:14,640
time that you perform an
operation calling this function,

50
00:02:14,640 --> 00:02:17,120
a series of lines of
code will be executed.

51
00:02:17,120 --> 00:02:18,400
You don't have to

52
00:02:18,400 --> 00:02:21,370
rewrite those lines of
code over and over again.

53
00:02:21,370 --> 00:02:22,710
You can reuse a function,

54
00:02:22,710 --> 00:02:24,390
you basically write it once

55
00:02:24,390 --> 00:02:27,540
and you can execute it as
many times as you want.

56
00:02:27,540 --> 00:02:29,990
Often what you will
see is a series of

57
00:02:29,990 --> 00:02:32,910
functions that are defined

58
00:02:32,910 --> 00:02:35,890
first and then later software

59
00:02:35,890 --> 00:02:38,240
that starts making use
of those functions.

60
00:02:38,240 --> 00:02:41,730
That makes it incredibly
easy to maintain,

61
00:02:41,730 --> 00:02:43,530
because if you see that there's

62
00:02:43,530 --> 00:02:45,550
a bug or a problem with
one of the functions,

63
00:02:45,550 --> 00:02:46,750
you're going to
fix the function.

64
00:02:46,750 --> 00:02:48,950
You don't have to go and repeat

65
00:02:48,950 --> 00:02:50,870
that correction in
the many instances

66
00:02:50,870 --> 00:02:53,255
in which you have
been using this code.

67
00:02:53,255 --> 00:02:56,905
If you would not write a
function in the first place.

68
00:02:56,905 --> 00:02:59,370
We're going to dive
in, let's jump into

69
00:02:59,370 --> 00:03:00,610
the next video and
we're going to start

70
00:03:00,610 --> 00:03:03,190
seeing how to write these
functions together.