WEBVTT

0
00:01.320 --> 00:05.340
Well done for completing today's course and challenges.

1
00:05.970 --> 00:14.430
Now, one of the questions I often see students ask in the Q&A is, "Okay, so I've written this code,

2
00:14.430 --> 00:18.120
this is my solution, but what's the right solution?"

3
00:18.750 --> 00:21.750
And this is something that I want to talk about today.

4
00:22.700 --> 00:28.500
And the really important thing for you to understand is that there is no right solution.

5
00:28.850 --> 00:30.310
It is your solution.

6
00:30.320 --> 00:34.220
It's about your thinking process and how you got there.

7
00:35.180 --> 00:41.390
And when you're looking at the solution, when you're looking at your code, the most important thing

8
00:41.390 --> 00:46.910
is not how fast does it run, or how few lines of code you use,

9
00:47.090 --> 00:48.530
how efficient is the code.

10
00:49.310 --> 00:55.940
To quote the godfather of computer programming, Donald Knuth, the guy who wrote The Art of Computer

11
00:55.940 --> 01:04.130
Science and many other books that are super influential, super hard to understand, but what he says is

12
01:04.700 --> 01:05.510
premature

13
01:05.510 --> 01:08.670
optimization is not a great thing.

14
01:09.140 --> 01:13.320
Don't try to make your code the most efficient as possible.

15
01:13.790 --> 01:17.080
Instead, what you should aim for is readability.

16
01:17.630 --> 01:23.750
So if another programmer comes along, if another student takes a look at your code, can they understand

17
01:23.750 --> 01:26.870
what you did immediately without a lot of effort?

18
01:27.290 --> 01:30.070
Well, if that's true, then you've succeeded.

19
01:30.470 --> 01:31.670
That is the goal.

20
01:31.680 --> 01:36.000
That is the bar that you should measure your code by. Now,

21
01:36.020 --> 01:42.470
when I was in university and I had to write a lot of essays, especially during the year when I was

22
01:42.470 --> 01:51.230
doing neuroscience as a degree, and when I first started writing essays, I thought, "You know what?

23
01:51.590 --> 01:54.380
Good essays are ones with big words.

24
01:54.380 --> 01:59.120
They're the ones with like, you know, the ones in the dictionary that like nobody ever uses."

25
01:59.660 --> 02:01.870
And they had to be really complex.

26
02:01.880 --> 02:03.620
It made me sound super smart.

27
02:04.460 --> 02:12.290
But then I had a professor who was somebody who really was very influential in my life.

28
02:12.290 --> 02:14.780
And he took one look at my essay and says,

29
02:15.880 --> 02:23.740
"This is not how you write. You write so that other people understand what you're trying to say."

30
02:25.070 --> 02:31.490
And it's actually the same thing with code. It's not about writing big words, it's not about shortening

31
02:31.490 --> 02:40.700
your code to the shortest number of lines. It's about making your code expressive, readable and as easily

32
02:40.700 --> 02:43.370
understood by as many people as possible.

33
02:44.420 --> 02:49.550
Once you've gotten there, eventually, you know, once you become a senior developer, you'll have

34
02:49.550 --> 02:57.350
your own ideas about style and syntax. But at this stage, optimize for readability.