1
00:00:00,420 --> 00:00:02,969
Now, I've got some final tips for debugging,

2
00:00:03,150 --> 00:00:07,770
and these are not so much techniques, but there are just really,

3
00:00:07,770 --> 00:00:11,820
really important tips from somebody who's done quite a lot of coding and created

4
00:00:12,180 --> 00:00:14,520
a massive amount of bugs in my lifetime.

5
00:00:15,150 --> 00:00:18,930
So tip number 7 is take a break. It's really,

6
00:00:18,930 --> 00:00:23,930
really important when you're just staring at the code and you keep looking at

7
00:00:24,480 --> 00:00:27,120
it, it's not going to tell you the solution.

8
00:00:27,360 --> 00:00:30,210
Just have a cup of tea or have a nap,

9
00:00:30,240 --> 00:00:32,850
or just go to sleep and try to tackle it tomorrow.

10
00:00:33,240 --> 00:00:38,100
You will be surprised just how much easier things are when your brains had some

11
00:00:38,100 --> 00:00:42,330
downtime and then you come back to it. Everything seems so much more obvious.

12
00:00:43,110 --> 00:00:47,850
And if you really, really get stuck and you just can't see it, ask a friend,

13
00:00:48,090 --> 00:00:51,540
not your friend print, but your actual friend,

14
00:00:51,570 --> 00:00:56,010
a real human. Preferably a developer, but they don't have to be.

15
00:00:56,040 --> 00:00:58,320
It could be somebody who's taking the course with you.

16
00:00:58,560 --> 00:01:03,450
You could go onto discord and find other students to help you because after all,

17
00:01:03,480 --> 00:01:06,150
you're all just leveling up your own programming skills

18
00:01:06,150 --> 00:01:10,890
right? The really good thing about asking a friend to look through your code is

19
00:01:11,100 --> 00:01:14,010
they won't make the same assumptions that you've made.

20
00:01:14,310 --> 00:01:17,310
So they have some fresh eyes that they can look at the code with,

21
00:01:17,550 --> 00:01:20,910
and it might be incredibly obvious what's actually happening.

22
00:01:21,270 --> 00:01:23,010
And it's really not embarrassing at all.

23
00:01:23,280 --> 00:01:25,320
If somebody managed to help you with your code,

24
00:01:25,830 --> 00:01:30,780
you can offer to help them the next time when they get stuck. And for the person

25
00:01:30,780 --> 00:01:31,650
who's helping you,

26
00:01:31,980 --> 00:01:36,390
they're also just working out their programming muscles, right? Now

27
00:01:36,390 --> 00:01:40,170
the next tip is to run often. No,

28
00:01:40,200 --> 00:01:43,260
you don't have to go exercising to be a good programmer.

29
00:01:43,860 --> 00:01:46,740
But what I mean is run your code often.

30
00:01:47,100 --> 00:01:51,000
Don't wait until you've written loads and loads of code to hit run

31
00:01:51,000 --> 00:01:54,090
and then find out you've got loads of snags and loads of bugs.

32
00:01:54,420 --> 00:01:57,330
But run it after every little execution.

33
00:01:57,750 --> 00:02:02,750
Once you feel like you've changed the program ever so slightly, run it. Confirm

34
00:02:02,820 --> 00:02:04,770
that it's actually doing what you want it to do,

35
00:02:05,400 --> 00:02:07,290
because if you leave it all to the end,

36
00:02:07,380 --> 00:02:11,760
then you end up with a pile of bugs and you don't know where to start. Now,

37
00:02:11,790 --> 00:02:16,680
if you do end up in that situation and you can see multiple bugs at the same

38
00:02:16,680 --> 00:02:19,410
time, try to tackle them one at a time

39
00:02:19,440 --> 00:02:23,280
instead of trying to do bits and bobs of each. It will really, really help.

40
00:02:24,210 --> 00:02:28,710
And the final tip is, of course, Stack Overflow. I've saved this the last

41
00:02:28,710 --> 00:02:33,030
because you really don't want to take every single small bug of yours to Stack

42
00:02:33,030 --> 00:02:36,300
Overflow, that's not what it's designed for. Instead,

43
00:02:36,330 --> 00:02:41,250
it's really designed as a way of asking other developers

44
00:02:41,610 --> 00:02:46,610
when you think that you've come across a bug or an issue that should be unique.

45
00:02:47,370 --> 00:02:51,240
Now, if you think that you issue isn't unique and other people should have

46
00:02:51,330 --> 00:02:54,240
encountered this, then just search Stack Overflow.

47
00:02:54,840 --> 00:02:58,410
If you really think that nobody in the world has had this issue that you are

48
00:02:58,410 --> 00:03:02,890
having right now, then that's the moment to ask the oracle, I mean Stack

49
00:03:02,890 --> 00:03:03,723
Overflow.

50
00:03:04,360 --> 00:03:08,290
I've worked in a lot of companies where everybody just goes to the part when

51
00:03:08,290 --> 00:03:11,980
Stack Overflow is down, because there's just no point. As programmers

52
00:03:12,010 --> 00:03:17,010
we use it and we search it so much and it's become a really vital tool in the tool

53
00:03:17,410 --> 00:03:18,243
belt.

54
00:03:18,400 --> 00:03:23,230
But you only wanna ask a question when you've pretty sure that you've exhausted

55
00:03:23,320 --> 00:03:28,090
all other avenues of debugging and you've searched all of Stack Overflow and you

56
00:03:28,090 --> 00:03:32,080
finally end up with something very strange and very weird that you want others

57
00:03:32,080 --> 00:03:35,680
to help you figure out. So don't worry about creating bugs.

58
00:03:35,710 --> 00:03:39,190
And hopefully at this point, you're creating friendly bugs,

59
00:03:39,190 --> 00:03:40,990
like this little Caterpillar right now.

60
00:03:41,380 --> 00:03:44,260
And as you scale up and become even more advanced,

61
00:03:44,530 --> 00:03:49,210
you're going to be creating bigger and more scary bugs.

62
00:03:49,750 --> 00:03:53,110
So at some point in the future, when you're creating bugs like these,

63
00:03:53,470 --> 00:03:56,260
then you really know that you've become a professional.

64
00:03:56,620 --> 00:04:00,610
You will wish to come back to today when you can tackle bugs like these 

65
00:04:00,630 --> 00:04:02,880
instead. So don't worry about

66
00:04:02,880 --> 00:04:06,450
about creating them. It doesn't mean that you are bad programmer. In fact,

67
00:04:06,450 --> 00:04:11,400
it's an important part of every programmer's journey. Just as a sort of personal

68
00:04:11,400 --> 00:04:11,670
note,

69
00:04:11,670 --> 00:04:15,570
there was a point in time where I've really thought that I was not a programmer of

70
00:04:15,570 --> 00:04:18,899
code, that I was just a programmer of bugs.

71
00:04:18,899 --> 00:04:21,810
It seemed like every line of code I wrote was a bug.

72
00:04:22,530 --> 00:04:25,800
So these are my 10 top tips for debugging.

73
00:04:26,100 --> 00:04:30,870
And I hope that any time when your code is not doing what you expect it to do to

74
00:04:30,870 --> 00:04:35,610
come back to this lesson, review these 10 steps, go through them one by one

75
00:04:36,060 --> 00:04:40,860
and I bet 99% of the time, once you've gone through all of these stages,

76
00:04:41,130 --> 00:04:45,000
you will have solved your bug and you will have made your code a lot better.

77
00:04:45,330 --> 00:04:50,330
And remember that every bug that you catch in your code and that you fix is like

78
00:04:50,580 --> 00:04:53,190
lifting a dumbbell in the gym. It's just one rep.

79
00:04:53,490 --> 00:04:57,930
And the more reps you do the better you'll get at programing. In the next

80
00:04:57,930 --> 00:05:01,800
lesson, I've got some coding challenges for you to debug.

81
00:05:02,340 --> 00:05:05,280
Are you ready to flex your programming muscles?

82
00:05:05,640 --> 00:05:08,850
I hope so. Head over to the next lesson and get started.

