Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,300 --> 00:00:07,470
Welcome back and now I'm going to tell you a little bit about the main reasons for using constants,
2
00:00:07,470 --> 00:00:12,810
because you may be wondering for yourselves as to why we even need them, right?
3
00:00:13,140 --> 00:00:19,470
Because that's not quite understandable, just to say that they are constant and that's it.
4
00:00:19,900 --> 00:00:27,360
OK, there are a lot of additional reasons and some of them I will cover up in this video.
5
00:00:29,200 --> 00:00:36,530
So you may be you may be thinking to yourself that we've been doing pretty well also with just using
6
00:00:36,530 --> 00:00:40,380
the variables, so why do we even need these constants for?
7
00:00:40,990 --> 00:00:46,180
I will tell you some of the reasons, but maybe and don't worry so much about it, maybe at this point,
8
00:00:46,180 --> 00:00:49,990
not all of them will seem to be like 100 percent clear to you.
9
00:00:50,650 --> 00:00:57,940
And that's OK, because most of them, most of the reasons are considered to be for quite a higher level
10
00:00:57,940 --> 00:00:59,230
programming courses.
11
00:00:59,680 --> 00:01:05,830
But I think that's something you must be familiar with, at least in my course, to be familiar with,
12
00:01:05,830 --> 00:01:13,570
not to implement everything regarding do, but at least to be familiar for these three main reasons.
13
00:01:14,500 --> 00:01:21,730
So with that being said, let us start and discuss the main reasons to use constants and domain ideas
14
00:01:22,000 --> 00:01:27,130
that I see for when and where you should consider using them.
15
00:01:29,100 --> 00:01:39,330
All right, so reason number one for using constants use performance so the compiler can perform certain
16
00:01:39,330 --> 00:01:44,340
optimizations for using loops as well as the usage of inline code.
17
00:01:44,580 --> 00:01:49,910
OK, also creates an object code that is parallelism friendly.
18
00:01:50,640 --> 00:01:57,870
That means simply if you are planning to develop complex applications and not just basic applications
19
00:01:57,870 --> 00:02:04,740
like we've we've seen that can be made, especially at the beginning of the program, at the beginning
20
00:02:04,740 --> 00:02:05,370
of the course.
21
00:02:06,300 --> 00:02:12,000
So basically, if you're planning to develop complex apps, I mean, like really complex applications
22
00:02:12,000 --> 00:02:21,600
with massive amount of, ah, commands and utilizing high CPU usage, a lot of commands, and basically
23
00:02:22,440 --> 00:02:29,160
you may want to do it in a parallel manner, splitting the processing and so on, then using constants
24
00:02:29,160 --> 00:02:30,870
will assist you with that.
25
00:02:32,810 --> 00:02:38,780
So that's reason number one and I'll let us talk about reason number two, and this reason is called
26
00:02:38,780 --> 00:02:39,940
defense.
27
00:02:40,580 --> 00:02:47,570
So using constants allows basically allows you to protect yourself from accidentally changing values
28
00:02:47,780 --> 00:02:49,350
when you are not supposed to.
29
00:02:50,060 --> 00:02:56,210
So it gives you another layer of protection by basically when you have some functions, when you have
30
00:02:56,210 --> 00:03:01,970
some program, when you when you know that some value should not be changed over time and during the
31
00:03:01,970 --> 00:03:04,190
execution or during some function.
32
00:03:04,730 --> 00:03:12,220
And you will specify these information that it's a constant and it should not get changed.
33
00:03:12,470 --> 00:03:18,080
So that this way, even if you've done some mistake, even if you modified it by mistake, I don't know
34
00:03:18,080 --> 00:03:25,580
or you forgot about it or something like that, then the compiler before the program will be built and
35
00:03:25,580 --> 00:03:32,960
run, the compiler will notify you that, hey, listen, you tried to change here, these value of this
36
00:03:32,960 --> 00:03:35,050
variable, but it's supposed to be constant.
37
00:03:35,330 --> 00:03:37,220
So please check it out again.
38
00:03:37,480 --> 00:03:40,930
OK, so that's another another layer of defense.
39
00:03:40,980 --> 00:03:49,460
OK, another layer of protection to make sure that your values that are supposed to be constant are
40
00:03:49,460 --> 00:03:51,500
not changed by mistake.
41
00:03:53,170 --> 00:03:54,020
Okey dokey.
42
00:03:54,590 --> 00:04:01,780
And finally, regarding the third reason, reason number three is code readability.
43
00:04:02,030 --> 00:04:10,190
OK, so when reading the code and sometimes there are me maybe so many lines of code, it's a good practice
44
00:04:10,190 --> 00:04:17,350
to use constants to specify the exact variables that, you know, they should not get changed.
45
00:04:18,020 --> 00:04:26,090
So that gives you a good understanding for the fact that you are using a constant variable, since you
46
00:04:26,090 --> 00:04:31,640
know that it's only defined here with its given value and it's not going to get modified during the
47
00:04:31,640 --> 00:04:32,950
execution of the program.
48
00:04:33,530 --> 00:04:39,350
And that's opposed, of course, to the standard variable that may change during any line of the program.
49
00:04:39,560 --> 00:04:44,870
And you have like to take a closer look and see where and how it's being used.
50
00:04:45,500 --> 00:04:51,740
So that's the third important reason that I wanted to tell you regarding the usage of constants in your
51
00:04:51,950 --> 00:04:59,720
program, in your development process, or basically when your exams, of course, you may also let
52
00:04:59,720 --> 00:05:02,750
me know if you find any additional.
53
00:05:02,990 --> 00:05:09,170
Of course, there are additional reasons for using constants, but I think that I just took they are
54
00:05:09,340 --> 00:05:12,350
most relevant in my opinion.
55
00:05:12,720 --> 00:05:23,810
Of course, you may also add additional ideas, additional reasons for why you consider using pointer
56
00:05:23,810 --> 00:05:25,130
are constants.
57
00:05:25,760 --> 00:05:26,960
And yeah.
58
00:05:26,960 --> 00:05:29,720
So as always, guys, thank you so much for watching.
59
00:05:29,720 --> 00:05:30,740
Keep on practicing.
60
00:05:30,740 --> 00:05:32,360
Keep on betting, getting better.
61
00:05:32,660 --> 00:05:36,680
And actually you're bound to succeed if you do it correctly.
62
00:05:37,280 --> 00:05:39,050
Hopefully so.
63
00:05:39,140 --> 00:05:40,130
Thank you guys for watching.
64
00:05:40,160 --> 00:05:40,940
My name is Vlad.
65
00:05:41,300 --> 00:05:43,790
These are an important video.
66
00:05:43,790 --> 00:05:49,480
And until the next time, until the next video or section or whatever it may be, have a great time.
67
00:05:49,490 --> 00:05:50,240
I'll see you then.
7167
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.