WEBVTT

0
00:00.420 --> 00:02.970
Now, I've got some final tips for debugging,

1
00:03.150 --> 00:07.770
and these are not so much techniques, but there are just really,

2
00:07.770 --> 00:11.820
really important tips from somebody who's done quite a lot of coding and created

3
00:12.180 --> 00:14.520
a massive amount of bugs in my lifetime.

4
00:15.150 --> 00:18.930
So tip number 7 is take a break. It's really,

5
00:18.930 --> 00:23.930
really important when you're just staring at the code and you keep looking at

6
00:24.480 --> 00:27.120
it, it's not going to tell you the solution.

7
00:27.360 --> 00:30.210
Just have a cup of tea or have a nap,

8
00:30.240 --> 00:32.850
or just go to sleep and try to tackle it tomorrow.

9
00:33.240 --> 00:38.100
You will be surprised just how much easier things are when your brains had some

10
00:38.100 --> 00:42.330
downtime and then you come back to it. Everything seems so much more obvious.

11
00:43.110 --> 00:47.850
And if you really, really get stuck and you just can't see it, ask a friend,

12
00:48.090 --> 00:51.540
not your friend print, but your actual friend,

13
00:51.570 --> 00:56.010
a real human. Preferably a developer, but they don't have to be.

14
00:56.040 --> 00:58.320
It could be somebody who's taking the course with you.

15
00:58.560 --> 01:03.450
You could go onto discord and find other students to help you because after all,

16
01:03.480 --> 01:06.150
you're all just leveling up your own programming skills

17
01:06.150 --> 01:10.890
right? The really good thing about asking a friend to look through your code is

18
01:11.100 --> 01:14.010
they won't make the same assumptions that you've made.

19
01:14.310 --> 01:17.310
So they have some fresh eyes that they can look at the code with,

20
01:17.550 --> 01:20.910
and it might be incredibly obvious what's actually happening.

21
01:21.270 --> 01:23.010
And it's really not embarrassing at all.

22
01:23.280 --> 01:25.320
If somebody managed to help you with your code,

23
01:25.830 --> 01:30.780
you can offer to help them the next time when they get stuck. And for the person

24
01:30.780 --> 01:31.650
who's helping you,

25
01:31.980 --> 01:36.390
they're also just working out their programming muscles, right? Now

26
01:36.390 --> 01:40.170
the next tip is to run often. No,

27
01:40.200 --> 01:43.260
you don't have to go exercising to be a good programmer.

28
01:43.860 --> 01:46.740
But what I mean is run your code often.

29
01:47.100 --> 01:51.000
Don't wait until you've written loads and loads of code to hit run

30
01:51.000 --> 01:54.090
and then find out you've got loads of snags and loads of bugs.

31
01:54.420 --> 01:57.330
But run it after every little execution.

32
01:57.750 --> 02:02.750
Once you feel like you've changed the program ever so slightly, run it. Confirm

33
02:02.820 --> 02:04.770
that it's actually doing what you want it to do,

34
02:05.400 --> 02:07.290
because if you leave it all to the end,

35
02:07.380 --> 02:11.760
then you end up with a pile of bugs and you don't know where to start. Now,

36
02:11.790 --> 02:16.680
if you do end up in that situation and you can see multiple bugs at the same

37
02:16.680 --> 02:19.410
time, try to tackle them one at a time

38
02:19.440 --> 02:23.280
instead of trying to do bits and bobs of each. It will really, really help.

39
02:24.210 --> 02:28.710
And the final tip is, of course, Stack Overflow. I've saved this the last

40
02:28.710 --> 02:33.030
because you really don't want to take every single small bug of yours to Stack

41
02:33.030 --> 02:36.300
Overflow, that's not what it's designed for. Instead,

42
02:36.330 --> 02:41.250
it's really designed as a way of asking other developers

43
02:41.610 --> 02:46.610
when you think that you've come across a bug or an issue that should be unique.

44
02:47.370 --> 02:51.240
Now, if you think that you issue isn't unique and other people should have

45
02:51.330 --> 02:54.240
encountered this, then just search Stack Overflow.

46
02:54.840 --> 02:58.410
If you really think that nobody in the world has had this issue that you are

47
02:58.410 --> 03:02.890
having right now, then that's the moment to ask the oracle, I mean Stack

48
03:02.890 --> 03:03.723
Overflow.

49
03:04.360 --> 03:08.290
I've worked in a lot of companies where everybody just goes to the part when

50
03:08.290 --> 03:11.980
Stack Overflow is down, because there's just no point. As programmers

51
03:12.010 --> 03:17.010
we use it and we search it so much and it's become a really vital tool in the tool

52
03:17.410 --> 03:18.243
belt.

53
03:18.400 --> 03:23.230
But you only wanna ask a question when you've pretty sure that you've exhausted

54
03:23.320 --> 03:28.090
all other avenues of debugging and you've searched all of Stack Overflow and you

55
03:28.090 --> 03:32.080
finally end up with something very strange and very weird that you want others

56
03:32.080 --> 03:35.680
to help you figure out. So don't worry about creating bugs.

57
03:35.710 --> 03:39.190
And hopefully at this point, you're creating friendly bugs,

58
03:39.190 --> 03:40.990
like this little Caterpillar right now.

59
03:41.380 --> 03:44.260
And as you scale up and become even more advanced,

60
03:44.530 --> 03:49.210
you're going to be creating bigger and more scary bugs.

61
03:49.750 --> 03:53.110
So at some point in the future, when you're creating bugs like these,

62
03:53.470 --> 03:56.260
then you really know that you've become a professional.

63
03:56.620 --> 04:00.610
You will wish to come back to today when you can tackle bugs like these 

64
04:00.630 --> 04:02.880
instead. So don't worry about

65
04:02.880 --> 04:06.450
about creating them. It doesn't mean that you are bad programmer. In fact,

66
04:06.450 --> 04:11.400
it's an important part of every programmer's journey. Just as a sort of personal

67
04:11.400 --> 04:11.670
note,

68
04:11.670 --> 04:15.570
there was a point in time where I've really thought that I was not a programmer of

69
04:15.570 --> 04:18.900
code, that I was just a programmer of bugs.

70
04:18.900 --> 04:21.810
It seemed like every line of code I wrote was a bug.

71
04:22.530 --> 04:25.800
So these are my 10 top tips for debugging.

72
04:26.100 --> 04:30.870
And I hope that any time when your code is not doing what you expect it to do to

73
04:30.870 --> 04:35.610
come back to this lesson, review these 10 steps, go through them one by one

74
04:36.060 --> 04:40.860
and I bet 99% of the time, once you've gone through all of these stages,

75
04:41.130 --> 04:45.000
you will have solved your bug and you will have made your code a lot better.

76
04:45.330 --> 04:50.330
And remember that every bug that you catch in your code and that you fix is like

77
04:50.580 --> 04:53.190
lifting a dumbbell in the gym. It's just one rep.

78
04:53.490 --> 04:57.930
And the more reps you do the better you'll get at programing. In the next

79
04:57.930 --> 05:01.800
lesson, I've got some coding challenges for you to debug.

80
05:02.340 --> 05:05.280
Are you ready to flex your programming muscles?

81
05:05.640 --> 05:08.850
I hope so. Head over to the next lesson and get started.