1
00:00:01,290 --> 00:00:02,870
My name is Ashish Mahabal and

2
00:00:02,870 --> 00:00:06,340
I'm going to be talking about
the best programming practices.

3
00:00:06,340 --> 00:00:07,910
This is the first part of that.

4
00:00:07,910 --> 00:00:13,060
The best programming practices,
there are many generic ones in that, but

5
00:00:13,060 --> 00:00:15,750
also depend a lot on which
programming language that you use,

6
00:00:15,750 --> 00:00:18,120
which package that we use and so on.

7
00:00:18,120 --> 00:00:20,350
We'll be seeing some of
the general ones and

8
00:00:20,350 --> 00:00:23,580
then we'll try to go into details
of only a few specific ones.

9
00:00:25,350 --> 00:00:29,670
Some of the things that you'll
need to remember are first thing,

10
00:00:29,670 --> 00:00:32,820
your code divides the universe into two.

11
00:00:32,820 --> 00:00:36,650
And if the code is good, then it is
going to lead to a better universe, and

12
00:00:36,650 --> 00:00:38,380
that is what you should try to do.

13
00:00:38,380 --> 00:00:42,000
And that is one purpose of telling
you a little bit about some of

14
00:00:42,000 --> 00:00:43,660
the best programming practices.

15
00:00:43,660 --> 00:00:46,400
And this will be not about just
the programming language, but

16
00:00:46,400 --> 00:00:49,610
also some related aspects of that.

17
00:00:49,610 --> 00:00:55,512
And the best practices related
to programming begin not with

18
00:00:55,512 --> 00:01:00,660
the program itself, but in that come in
very specific things like variable names.

19
00:01:00,660 --> 00:01:04,005
Radius subroutines, the structure
of the program, and evolution and

20
00:01:04,005 --> 00:01:05,940
well-being of the program itself.

21
00:01:05,940 --> 00:01:07,710
So, what does one mean by that?

22
00:01:07,710 --> 00:01:13,010
It's easy to, to coding just by instinct,
use variable names that are single

23
00:01:13,010 --> 00:01:19,640
letter like a, b, c or just x, y, z and
that is a bad thing to do, because.

24
00:01:19,640 --> 00:01:21,710
At this problem the moment seems fine, but

25
00:01:21,710 --> 00:01:24,760
when down the line, later on,
you come back to that, or

26
00:01:24,760 --> 00:01:28,970
someone else is reading the code, then
they may or may not make sense to them.

27
00:01:28,970 --> 00:01:31,700
And you sometimes send to all
write such values easily.

28
00:01:31,700 --> 00:01:35,010
So, you need to be a little bit
careful about what variables that you,

29
00:01:35,010 --> 00:01:37,710
the names of variables that you use.

30
00:01:37,710 --> 00:01:40,750
And then how to write those
will come to that specifically.

31
00:01:40,750 --> 00:01:41,950
The other component,

32
00:01:41,950 --> 00:01:45,640
the slightly bigger component is
the sub routine senior program.

33
00:01:45,640 --> 00:01:47,810
Those are the most critical parts and

34
00:01:47,810 --> 00:01:51,590
program, because they determine
the structure of a program, and

35
00:01:51,590 --> 00:01:55,660
coming up with proper ones for
the names and the functionality is good.

36
00:01:55,660 --> 00:02:00,270
So we will be seeing how the structure
of a function should be.

37
00:02:00,270 --> 00:02:02,030
What the function should be doing.

38
00:02:02,030 --> 00:02:04,990
How the different functions should
interact with each other, and

39
00:02:04,990 --> 00:02:09,180
how they should be dependent, and
not be dependent on each other as well.

40
00:02:09,180 --> 00:02:12,410
And that, in general,
defines the structure of a program.

41
00:02:13,910 --> 00:02:16,340
That then leads you to
the evolution of the program,

42
00:02:16,340 --> 00:02:21,280
because it rarely happens that you write
a program, and the program stays as it is.

43
00:02:21,280 --> 00:02:25,530
Because down the line, you think of
new things, or bugs are reported, so

44
00:02:25,530 --> 00:02:28,990
you are going to go and change that,
and the program is going to evolve.

45
00:02:28,990 --> 00:02:32,890
So, when you start writing a program,
or a package, or a module.

46
00:02:32,890 --> 00:02:36,430
You have to keep in mind that this
evolution is going to happen, and

47
00:02:36,430 --> 00:02:39,200
you have to plan for that accordingly.

48
00:02:39,200 --> 00:02:44,270
And the well-being is in terms of
the maintenance of the program.

49
00:02:44,270 --> 00:02:48,340
You will be maintaining the program
initially or if you are part of a team,

50
00:02:48,340 --> 00:02:50,910
the team will be maintaining the program.

51
00:02:50,910 --> 00:02:52,736
So that too has to be kept in mind.

52
00:02:52,736 --> 00:02:56,160
The program, the [INAUDIBLE] has
to be written in such a fashion,

53
00:02:56,160 --> 00:02:58,270
that the maintenance is
also going to be easy.

54
00:03:00,360 --> 00:03:03,840
So there are distinct function that

55
00:03:03,840 --> 00:03:08,310
are distinct ways in which you can use
the best programming practices, and

56
00:03:08,310 --> 00:03:10,080
depending on language
that's going be different.

57
00:03:10,080 --> 00:03:12,690
But one of a generic book
that I can suggest to

58
00:03:12,690 --> 00:03:15,000
you is The Pragmatic Programmer.

59
00:03:15,000 --> 00:03:19,457
By Andrew Hunt and David Thomas,
you should definitely take a look at that.

60
00:03:19,457 --> 00:03:21,860
For our specific programs, like Phyton.

61
00:03:21,860 --> 00:03:26,640
There are some [INAUDIBLE] and
we'll be seeing more of that but

62
00:03:26,640 --> 00:03:29,630
import this is the standard
thing that you can and

63
00:03:29,630 --> 00:03:33,410
that tells you what kind of
functionality that specific best

64
00:03:33,410 --> 00:03:37,540
programming practice that can bring
in [INAUDIBLE] seeing more of that.

65
00:03:37,540 --> 00:03:43,730
Now before going forward with any other
specific comments one meta comment I

66
00:03:43,730 --> 00:03:48,430
would like to make about best programming
practices is using source code control.

67
00:03:48,430 --> 00:03:52,330
That is one thing that will be
the most benefiting to you and

68
00:03:52,330 --> 00:03:54,190
your other team members.

69
00:03:54,190 --> 00:03:59,620
Source code control, allows you for
different versions to be stored.

70
00:03:59,620 --> 00:04:01,120
That's one of the things.

71
00:04:01,120 --> 00:04:03,500
And there are many other
benefits of course.

72
00:04:03,500 --> 00:04:09,860
So, typically, a new programmer starts
having, writing the first program,

73
00:04:09,860 --> 00:04:14,895
and it may be called something
like MyProgram_1.pi, for instance.

74
00:04:14,895 --> 00:04:18,278
[SOUND] And
then the program is written, it is run.

75
00:04:18,278 --> 00:04:19,690
Something is done with it.

76
00:04:19,690 --> 00:04:22,330
And then,
when some changes are to be made.

77
00:04:22,330 --> 00:04:26,155
Invariably, the program
becomes MyProgram_2.pi.

78
00:04:26,155 --> 00:04:29,850
And soon enough,
it becomes MyProgram_3.pi.

79
00:04:29,850 --> 00:04:32,980
And then it can be 3A and 3B.

80
00:04:32,980 --> 00:04:35,980
Where you had some subroutines,
take some subroutines out.

81
00:04:35,980 --> 00:04:38,780
You combine some subroutines and so on.

82
00:04:38,780 --> 00:04:40,750
And soon enough you forget,

83
00:04:40,750 --> 00:04:43,020
which subroutine had which
changes that were made,

84
00:04:43,020 --> 00:04:48,310
and what are the functionalities that
either you took out or took in and so on.

85
00:04:48,310 --> 00:04:51,020
So, in order for

86
00:04:51,020 --> 00:04:54,430
making all that transparent,
you can use Source Code Control.

87
00:04:54,430 --> 00:04:57,500
And what Source Code Control
allows you to do is,

88
00:04:57,500 --> 00:05:00,860
multiple people can work on the same
piece of code in a transparent version.

89
00:05:00,860 --> 00:05:04,900
You can keep one making changes to
your program, and comment it so

90
00:05:04,900 --> 00:05:08,080
that they all stay in a coherent fashion.

91
00:05:08,080 --> 00:05:12,660
And there are many different systems that
get used for a, source code control.

92
00:05:12,660 --> 00:05:17,030
The concurrent version CVS has
been used for a long time.

93
00:05:17,030 --> 00:05:19,570
That problem, that has been solved for
a long time, but

94
00:05:19,570 --> 00:05:22,630
there have been many changes and
improvements that have been made

95
00:05:22,630 --> 00:05:27,820
over time, Apache Subversion is something
that get used a lot these days, and

96
00:05:27,820 --> 00:05:32,300
Git is another similar
system that is used.

97
00:05:32,300 --> 00:05:36,200
So we've seen a little detail of that,
but we can not go in to more detail, but

98
00:05:36,200 --> 00:05:39,750
enough help is available on
these at radius location.

99
00:05:39,750 --> 00:05:43,190
So, I encourage you to look at it and
use that lot.

100
00:05:43,190 --> 00:05:46,470
So, let's quickly look at what cycle of

101
00:05:46,470 --> 00:05:49,230
such a change through
Source Code Control can look like.

102
00:05:49,230 --> 00:05:50,970
Here we see SVN cycle, and

103
00:05:50,970 --> 00:05:55,530
there are four words you can see there
are checkin, checkout, comment, and merge.

104
00:05:55,530 --> 00:05:59,560
So, the repository that you
see at the top of the picture,

105
00:05:59,560 --> 00:06:02,200
that is where all the code sits.

106
00:06:02,200 --> 00:06:05,120
And then,
you decide to interact with that code.

107
00:06:05,120 --> 00:06:10,830
So typically, your first step is
where you make a local copy of it.

108
00:06:10,830 --> 00:06:13,410
That is where you
are checking out the code.

109
00:06:13,410 --> 00:06:16,880
Once you do that, then you're
free to make changes to the code.

110
00:06:16,880 --> 00:06:21,410
And then update the code and add some
features, maybe take some bugs out.

111
00:06:21,410 --> 00:06:26,030
And when you do that you will add
comments, what is it that you have done,

112
00:06:26,030 --> 00:06:31,338
and then when it is time you will
want to update the committed

113
00:06:31,338 --> 00:06:34,840
comment the updated quote and
that is where merging can come in.

114
00:06:34,840 --> 00:06:39,330
Because if at the same time two different
people are working on the code, then it is

115
00:06:39,330 --> 00:06:44,040
possible through something like SVN to
merge the code in a flawless manner.

116
00:06:44,040 --> 00:06:46,640
And that is where you
check your code back in.

117
00:06:46,640 --> 00:06:49,780
So this is the cycle that
you will typically be using.

118
00:06:49,780 --> 00:06:54,350
Check out the code, make changes, update
slash commit, and which is your check in.

119
00:06:55,590 --> 00:07:01,100
There are cycle for git is similar,
the diagram seems slightly different,

120
00:07:01,100 --> 00:07:03,170
git is a more distributed system.

121
00:07:03,170 --> 00:07:06,010
But, again you'll see that
our four columns here,

122
00:07:06,010 --> 00:07:11,510
one is a workspace, another is index,
local repository, and remote repository.

123
00:07:11,510 --> 00:07:16,160
So, what you do is that from remote
repository you can fetch some code.

124
00:07:16,160 --> 00:07:18,140
That comes down to local depository.

125
00:07:18,140 --> 00:07:21,570
And then your workspace,
you can make changes to that.

126
00:07:21,570 --> 00:07:25,857
And through a command like add command,
you can tell that,

127
00:07:25,857 --> 00:07:30,910
that has to be added to the index and
that should be looking at it.

128
00:07:30,910 --> 00:07:34,360
And then when you do a commit, it
actually gets added to local repository.

129
00:07:34,360 --> 00:07:37,160
So you can keep playing
around things can stay in

130
00:07:37,160 --> 00:07:40,450
your local repository until you push.

131
00:07:40,450 --> 00:07:44,480
When you push the core back, it goes
back into the central remote repository,

132
00:07:44,480 --> 00:07:47,170
may not be a single location, so
it doesn't have to be central.

133
00:07:47,170 --> 00:07:51,880
It's only notionally central, because git
repositories can be very distributed.

134
00:07:51,880 --> 00:07:56,150
So, this cycle will allow you
to keep your code safe, and

135
00:07:56,150 --> 00:07:58,390
let multiple people work on it.

136
00:07:58,390 --> 00:08:02,200
If you get just one thing out of this
best programming practices video,

137
00:08:02,200 --> 00:08:06,460
it should be that you should try to
use control as much as possible.

138
00:08:06,460 --> 00:08:09,080
You want to regulate that.

139
00:08:09,080 --> 00:08:11,650
And now many,
many online hubs are coming about,

140
00:08:11,650 --> 00:08:14,970
where you don't really [COUGH]
have to have your own repository.

141
00:08:14,970 --> 00:08:19,800
You can use something like GitHub or
Bitbucket where git is built in.

142
00:08:19,800 --> 00:08:24,180
And that way what you do is that you can
fork someone else's code, or have your

143
00:08:24,180 --> 00:08:28,990
own private or public repositories,
have other team members working on it.

144
00:08:28,990 --> 00:08:33,580
Google Drive is something similar,
but for general documents, so

145
00:08:33,580 --> 00:08:35,620
that's another thing you can be using.

146
00:08:35,620 --> 00:08:38,970
Or if you want to write papers
collaboratively you can use a tool

147
00:08:38,970 --> 00:08:40,100
like Authorea.

148
00:08:40,100 --> 00:08:43,550
And if you are just interested in
latexing then there are sites like

149
00:08:43,550 --> 00:08:45,650
sharelatex and writelatex.

150
00:08:45,650 --> 00:08:49,830
Those are equally versatile in
being able to write papers.

151
00:08:49,830 --> 00:08:52,920
So in general again source
code control will allow you

152
00:08:53,950 --> 00:08:58,600
write code in different ways, but these
other collaborative tools which are really

153
00:08:58,600 --> 00:09:01,900
mushrooming out there will
allow you to use do more work.

154
00:09:03,190 --> 00:09:05,330
So coming specifically to coding.

155
00:09:06,660 --> 00:09:08,390
You can start coding by instinct.

156
00:09:08,390 --> 00:09:11,840
That is what everyone does, but that is
something that you should avoid doing.

157
00:09:11,840 --> 00:09:14,040
So coming specifically to variable names,

158
00:09:14,040 --> 00:09:18,760
there are many ways in which you can use
variables, and here I have mentioned five.

159
00:09:18,760 --> 00:09:21,540
You can have the UpperCamelCase
where sometimes your

160
00:09:21,540 --> 00:09:26,530
variable name has multiple words in it,
and you put the words next to each other,

161
00:09:26,530 --> 00:09:31,040
such as all, except the first
letter of each word are lowercase.

162
00:09:31,040 --> 00:09:34,830
That's why in UpperCamelCase you see U,
C and C to be uppercase.

163
00:09:34,830 --> 00:09:37,300
That's one way of using variable names.

164
00:09:37,300 --> 00:09:42,670
The second way is where you have only the
first word's first letter also lower case.

165
00:09:42,670 --> 00:09:45,150
So lower, first letter upper case, and

166
00:09:45,150 --> 00:09:50,850
then other lower case, and other words
also have their first letter upper case.

167
00:09:50,850 --> 00:09:56,660
Now this is, in my opinion, the best one,
because the first case is, is,

168
00:09:56,660 --> 00:10:01,220
some languages use upper case first
letters for their own keywords, and

169
00:10:01,220 --> 00:10:04,850
that clashes with that whereas this lower
camel case doesn't clash with that.

170
00:10:04,850 --> 00:10:09,240
The third possibility is all lower case,
but then it loses re, readability and

171
00:10:09,240 --> 00:10:10,800
it's pretty bad in my opinion.

172
00:10:12,520 --> 00:10:15,150
You could also have things that
are period separated, but again,

173
00:10:15,150 --> 00:10:19,550
that clashes with some languages having
modules, which are used in that fashion so

174
00:10:19,550 --> 00:10:21,440
that's again not a very good idea.

175
00:10:21,440 --> 00:10:23,330
Or you can have things
underscore separated.

176
00:10:23,330 --> 00:10:26,050
That is another good thing for
readability.

177
00:10:26,050 --> 00:10:30,150
But then if you are using latex then you
may have to take special care of not

178
00:10:30,150 --> 00:10:33,360
using it that way or
using a sensible lipec reader,

179
00:10:33,360 --> 00:10:37,070
which knows when it is a variable
name that you are using.

180
00:10:37,070 --> 00:10:39,210
So, in general one thing that I would,

181
00:10:39,210 --> 00:10:43,300
I would advise is that you should
adopt a very consistent naming system.

182
00:10:44,690 --> 00:10:48,730
Same thing goes four loops, there are many
ways in which you can write loops.

183
00:10:48,730 --> 00:10:51,580
There are four loops and
y loops for instance.

184
00:10:51,580 --> 00:10:55,560
And you should know the strengths
of the language that you are using.

185
00:10:55,560 --> 00:10:57,730
That is another best programming practice,

186
00:10:57,730 --> 00:11:03,390
because that will allow you to work with
the strongest points of the language.

187
00:11:03,390 --> 00:11:04,090
In Python, for

188
00:11:04,090 --> 00:11:08,950
instance, the four loop allows an else
clause so you can have a variable run so

189
00:11:08,950 --> 00:11:13,190
many times, but once it is out of it,
the else part of it can also go in.

190
00:11:13,190 --> 00:11:16,850
Or it can work with something like
dictionaries where you have got keys and

191
00:11:16,850 --> 00:11:22,240
value pairs, and it will take one by
one all the keys and work on that.

192
00:11:22,240 --> 00:11:26,240
And then, you should also know how
to avoid using explicit loops,

193
00:11:26,240 --> 00:11:31,420
when the language has ways
of running faster the loop.

194
00:11:31,420 --> 00:11:34,600
So here are some examples
that one can look at.

195
00:11:34,600 --> 00:11:39,350
Think of this problem where you want
to add all multiples of three and

196
00:11:39,350 --> 00:11:40,620
five below thousand.

197
00:11:40,620 --> 00:11:44,820
A simple way to do that is indicated
at the top of this page here.

198
00:11:44,820 --> 00:11:52,150
You can go from you can let your n go from
zero to 1,000 or below 1,000 and then if.

199
00:11:52,150 --> 00:11:54,950
When you divide it by the three or
five, the remainder is zero.

200
00:11:54,950 --> 00:11:58,050
You simply add that number,
and that's what your print.

201
00:11:58,050 --> 00:12:01,390
So you get all,
you get sums of all numbers below

202
00:12:01,390 --> 00:12:04,840
thousands that are multiples
of either three or five.

203
00:12:04,840 --> 00:12:08,730
But you can do the same thing
using something like num pi.

204
00:12:08,730 --> 00:12:12,328
And using modulus like these
which are easy to use,

205
00:12:12,328 --> 00:12:17,950
makes the programming much more fun and
also faster.

206
00:12:17,950 --> 00:12:21,900
Here, what we are doing is that we
are using a lube in an explicit fashion.

207
00:12:21,900 --> 00:12:26,750
We're using the x and simply checking
whether it's divisible by three or five.

208
00:12:26,750 --> 00:12:30,080
In the third case we are going
one step better, because here we

209
00:12:30,080 --> 00:12:33,370
are not checking explicitly for
remainders but just stepping.

210
00:12:33,370 --> 00:12:37,580
Through zero to thousand in steps of three
and steps of five, and then steps of

211
00:12:37,580 --> 00:12:42,410
15 which takes out those, if,
if clauses making the program much faster.

212
00:12:42,410 --> 00:12:46,840
So that is essentially what you need to
be able to do, using horses for courses.

213
00:12:46,840 --> 00:12:50,840
And so, knowing all the strengths
of the programming language,

214
00:12:50,840 --> 00:12:53,659
how to use different kinds of loops,
will allow you to do that.

215
00:12:55,610 --> 00:12:57,340
So, besides variable names and

216
00:12:57,340 --> 00:13:00,890
types of loops, there is also the issue
of formatting Python and Fortran.

217
00:13:02,260 --> 00:13:06,590
They say you have to use specific
ways of in writing the code,

218
00:13:06,590 --> 00:13:09,780
but the languages let you be more unruly.

219
00:13:09,780 --> 00:13:12,180
And that can sometimes
lead to very bad code.

220
00:13:12,180 --> 00:13:16,080
But if you are disciplined enough with
your indentation, with your brackets,

221
00:13:16,080 --> 00:13:16,920
with your braces and

222
00:13:16,920 --> 00:13:20,840
with your semicolons then your code
is going to be much better that way.

223
00:13:20,840 --> 00:13:23,830
So the main thing to
do is be conscious and

224
00:13:23,830 --> 00:13:26,430
consistent in the programming
style that you use.

225
00:13:26,430 --> 00:13:30,890
And if you are that way then you'll
find that others find your code to

226
00:13:30,890 --> 00:13:31,760
be much better.

227
00:13:33,830 --> 00:13:36,640
I mentioned earlier about, import this.

228
00:13:36,640 --> 00:13:39,280
And that started,
that came about as a poem, in fact,

229
00:13:39,280 --> 00:13:41,920
that was written by Tim Peters in 2004.

230
00:13:41,920 --> 00:13:45,100
It has 19 items in that.

231
00:13:45,100 --> 00:13:47,620
And I am highlighting
only a few of them here.

232
00:13:47,620 --> 00:13:50,670
So, one of them is explicit
is better than implicit.

233
00:13:50,670 --> 00:13:55,349
And this is specifically, in terms of
typecasting, rather than do assignments.

234
00:13:56,620 --> 00:14:01,740
As I said earlier four loops you can use
them in an implicit fashion but when your

235
00:14:01,740 --> 00:14:05,510
namespace and when you have type casting
when you are saying that this integer

236
00:14:05,510 --> 00:14:09,350
should be converted to flow to flow
should be converted to integer and so on.

237
00:14:09,350 --> 00:14:11,620
It is better to be explicit about that.

238
00:14:11,620 --> 00:14:16,830
Because otherwise what could happen is
that people can make mistakes there and

239
00:14:16,830 --> 00:14:20,760
thereby reading the code may not be
obvious that is what is happening.

240
00:14:20,760 --> 00:14:22,590
Then readability counts.

241
00:14:22,590 --> 00:14:26,450
Even if you're very clever, try to avoid
being very clever in your programs,

242
00:14:26,450 --> 00:14:30,220
because six months down the line
you may forget why you were being

243
00:14:30,220 --> 00:14:34,420
clever that what it was, what the clever
thing was that you were doing then so on.

244
00:14:35,890 --> 00:14:38,390
Similarly when you want to do a change.

245
00:14:39,670 --> 00:14:41,400
Many times now is better than never.

246
00:14:41,400 --> 00:14:45,370
If you want to add a feature you have
thought of it, it's better to do it soon,

247
00:14:45,370 --> 00:14:48,130
rather than not do it at all,
because you have thought of it.

248
00:14:48,130 --> 00:14:50,880
But at the same time the next
clause goes with that,

249
00:14:50,880 --> 00:14:53,920
that never may be better
than doing it right now.

250
00:14:53,920 --> 00:14:56,920
Because when you want to implement
some change, I mean you want to

251
00:14:56,920 --> 00:15:01,420
do a modification to a program,
you need to put some thought in that.

252
00:15:01,420 --> 00:15:02,610
If you don't do that,

253
00:15:02,610 --> 00:15:06,450
then it's likely to cause changes
somewhere else which were unintended.

254
00:15:06,450 --> 00:15:10,940
So rather than be in a rush,
be in a hurry, you better slow down a bit,

255
00:15:10,940 --> 00:15:15,160
think about it, and then make the change
rather than just right away doing that.

256
00:15:15,160 --> 00:15:17,300
The name-spaces are one
honking great idea.

257
00:15:17,300 --> 00:15:18,630
Let's do more of those.

258
00:15:18,630 --> 00:15:21,760
That is what allows you
to keep things coherent.

259
00:15:21,760 --> 00:15:26,020
That is what allows you to not
muddy other subroutine spaces.

260
00:15:26,020 --> 00:15:27,450
So you have some related terms.

261
00:15:27,450 --> 00:15:29,420
They go together quite well.

262
00:15:29,420 --> 00:15:32,080
And then if you use various
different kinds of terms,

263
00:15:32,080 --> 00:15:36,070
very likely, other subroutines, other
programs are going to use the same ones.

264
00:15:36,070 --> 00:15:39,410
And then you'll find that
one sub-routine spaces or

265
00:15:39,410 --> 00:15:42,050
writing another sub-routine
space if you're not careful.

266
00:15:44,360 --> 00:15:50,040
So, overall, this is how
a modification cycle should look for

267
00:15:51,130 --> 00:15:55,060
any change that you want to do, any
programming change that you want to do.

268
00:15:55,060 --> 00:15:57,610
The ones that in, that are in red,
we already seen that.

269
00:15:57,610 --> 00:15:59,720
So, you check out code.

270
00:15:59,720 --> 00:16:03,020
You make some changes to it,
you edit the readme.

271
00:16:03,020 --> 00:16:06,480
And then after that, once you are happy
with that, you check-in the code.

272
00:16:06,480 --> 00:16:09,305
So the part that is between
making the change and

273
00:16:09,305 --> 00:16:12,000
check-in is compiling
the program of course,

274
00:16:12,000 --> 00:16:15,020
when you make a change you
are going to see that it runs well.

275
00:16:16,050 --> 00:16:19,250
And then you'll see more
things that are about testing.

276
00:16:19,250 --> 00:16:20,890
We have not talked about tests yet.

277
00:16:20,890 --> 00:16:23,870
We'll come to those in more detail,
but here I wanted to

278
00:16:23,870 --> 00:16:27,600
point that out specifically as
a part of the modification cycle.

279
00:16:27,600 --> 00:16:32,620
So, what you need to do is, suppose you've
got a program here that has certain

280
00:16:32,620 --> 00:16:35,750
features, and on the right hand side
is where you'd like to go because.

281
00:16:35,750 --> 00:16:38,860
This doesn't have certain he
wants to add certain features,

282
00:16:38,860 --> 00:16:43,080
or this has some bags and you want to
remove those bags and reach here anyway.

283
00:16:43,080 --> 00:16:44,980
So, you want to go from here to here.

284
00:16:44,980 --> 00:16:46,980
Now clearly,

285
00:16:46,980 --> 00:16:51,730
this final program will be able to loose
something that this program cannot do.

286
00:16:51,730 --> 00:16:55,340
So, you should start by writing a test,
which this program is going to

287
00:16:55,340 --> 00:16:59,480
pass with the program on my left
hand side is not going to pass.

288
00:16:59,480 --> 00:17:04,350
And in the current state of the program,
clearly that test should fail.

289
00:17:04,350 --> 00:17:08,720
You should ensure that it indeed fails,
because if it passes anyway, then clearly

290
00:17:08,720 --> 00:17:12,040
what happens is that you don't really need
the modification that you're thinking of.

291
00:17:13,080 --> 00:17:15,480
Once that happens then you
should check out the code.

292
00:17:16,610 --> 00:17:18,260
Once you have checked out the code,

293
00:17:18,260 --> 00:17:20,830
then you should make the changes
that you want to do.

294
00:17:20,830 --> 00:17:24,320
Now come by and
now you are test whether pass.

295
00:17:24,320 --> 00:17:27,640
Because you have made the change and
that is why the test is going to pass on.

296
00:17:27,640 --> 00:17:30,080
And once that passes then
you can do a check in.

297
00:17:30,080 --> 00:17:33,530
So that is where you're modification
cycle has been completed, and

298
00:17:33,530 --> 00:17:36,690
if you follow that again for
all your programming changes.

299
00:17:36,690 --> 00:17:40,310
Then your code is going to stay
healthy for a very long time.

300
00:17:40,310 --> 00:17:43,490
This is a simple test that
one can see in python.

301
00:17:43,490 --> 00:17:46,260
One can use data unit test module.

302
00:17:46,260 --> 00:17:50,850
And here we are importing unit test, and
we are defining a very simple function.

303
00:17:50,850 --> 00:17:55,520
The function fun takes one argument, adds
one to it and just returns that number.

304
00:17:55,520 --> 00:17:58,280
So it's implementing
the input that it's assuming.

305
00:17:58,280 --> 00:18:01,530
And then you see the last
statement of this program,

306
00:18:01,530 --> 00:18:05,680
which is self.assertEqual,
which takes two arguments.

307
00:18:05,680 --> 00:18:08,790
The first argument is
the call to the function.

308
00:18:08,790 --> 00:18:12,820
And the second argument is what you
expect that call to return, and

309
00:18:12,820 --> 00:18:16,050
the two have to be the same
if the test passes, and

310
00:18:16,050 --> 00:18:18,860
that is what you essentially
need to make sure of.

311
00:18:18,860 --> 00:18:23,170
So, when you call it by these two
arguments it's going return true,

312
00:18:23,170 --> 00:18:27,970
if the test passes, you should do that
every time you want to make a change.

313
00:18:27,970 --> 00:18:30,020
And we'll be seeing
more about tests later.

314
00:18:31,370 --> 00:18:34,130
So, with that we come to the end
of the first part of this module.

315
00:18:34,130 --> 00:18:37,640
Next time we'll be looking
at project requirements and

316
00:18:37,640 --> 00:18:39,620
variousnesses in radiance of a program.

