1 00:00:00,530 --> 00:00:07,490 Let's talk about another developer fundamental and this one is commenting your code. 2 00:00:08,290 --> 00:00:13,030 Up until now, you may have seen me comment, add comments to our scripts. 3 00:00:13,740 --> 00:00:22,080 For example, right here I added a comment of Booleans and this tells the Python interpreter, Hey, 4 00:00:22,080 --> 00:00:24,360 this is a comment, don't run this. 5 00:00:24,390 --> 00:00:25,620 It's just for me. 6 00:00:25,620 --> 00:00:28,470 You can just ignore it and skip over to line two. 7 00:00:28,740 --> 00:00:29,910 And you saw that? 8 00:00:29,910 --> 00:00:32,970 I simply did that in Python with the pound sign. 9 00:00:33,000 --> 00:00:38,880 As soon as Python sees a pound sign, it adds a comment and you can do that after a line as well. 10 00:00:38,880 --> 00:00:45,030 I can say this assigns to a variable. 11 00:00:46,530 --> 00:00:52,020 And although this may look like two lines, it's actually just the ward rapping that's happening. 12 00:00:52,410 --> 00:00:56,340 And you can see that the interpreter just completely ignores these comments. 13 00:00:56,850 --> 00:01:02,070 Now, commenting sounds very, very simple, but it's an important concept. 14 00:01:02,070 --> 00:01:07,800 And if you want to be a good programmer in all languages, we have commenting. 15 00:01:07,800 --> 00:01:11,190 But there's good ways and bad ways of commenting. 16 00:01:12,170 --> 00:01:14,330 And this is something that comes with practice. 17 00:01:14,330 --> 00:01:18,050 But here are some key guidelines. 18 00:01:18,750 --> 00:01:25,410 When you're commenting your code, the idea is that you're adding valuable comments. 19 00:01:25,950 --> 00:01:39,840 That is, if I add a comment here that says, Hey, this is a sign name variable, a value of Andre 20 00:01:39,840 --> 00:01:43,230 string, a comment like this. 21 00:01:44,070 --> 00:01:45,360 Is not really good. 22 00:01:45,390 --> 00:01:46,620 Why is that? 23 00:01:46,650 --> 00:01:52,470 Well, because your code should be self explanatory, right? 24 00:01:52,500 --> 00:01:58,140 The idea is for us to write code that is easy to read, easy to understand. 25 00:01:58,140 --> 00:02:00,070 It's not trying to be clever. 26 00:02:00,090 --> 00:02:02,430 Instead, it should read like English. 27 00:02:02,580 --> 00:02:10,229 And any python programmer would know that here we're just simply adding Andre as a value of name. 28 00:02:10,229 --> 00:02:15,540 We're assigning a variable and adding a comment like this that's self explanatory. 29 00:02:15,540 --> 00:02:18,360 Just adds clutter to your code. 30 00:02:19,170 --> 00:02:20,830 So there's a trade off here. 31 00:02:20,850 --> 00:02:27,090 It's good to comment your code for let's say if you're working on teams and other developers come and 32 00:02:27,090 --> 00:02:28,770 they want to understand your code. 33 00:02:28,920 --> 00:02:34,170 But you have to remember this principle of code being easy to read. 34 00:02:35,130 --> 00:02:40,200 The only time you want to add comments to your code is. 35 00:02:40,350 --> 00:02:47,190 Well, when something really, really important is happening, where it might be a little complex, 36 00:02:47,400 --> 00:02:52,740 you first decide, Hey, is this code written in a way that makes sense? 37 00:02:52,740 --> 00:02:55,530 For example, if this was variable a. 38 00:02:56,280 --> 00:02:58,890 And this was variable B. 39 00:03:01,040 --> 00:03:04,130 Well, this might be really hard for somebody to understand. 40 00:03:04,130 --> 00:03:08,510 So you might say that this is is flag. 41 00:03:09,530 --> 00:03:15,690 But before you add that comment, you want to say to yourself, Hmm, maybe my code is hard to read. 42 00:03:15,710 --> 00:03:21,290 Maybe I should just change the variable to is cool to make it more understandable. 43 00:03:22,140 --> 00:03:29,790 Now this is something that you improve upon more and more, and you do want to use comments as an extra 44 00:03:29,790 --> 00:03:31,720 tool to make your code understandable. 45 00:03:31,740 --> 00:03:36,540 Maybe you write code that six months from now you want to go back to understand what you did. 46 00:03:37,050 --> 00:03:41,790 But remember, more comments doesn't necessarily mean better code. 47 00:03:42,180 --> 00:03:51,000 You want to be concise and keeping things simple while adding comments only when necessary to help others 48 00:03:51,000 --> 00:03:56,160 understand your code, not trying to make your unreadable code more readable. 49 00:03:56,640 --> 00:04:00,960 We'll explore this topic and give you advice on it throughout the course. 50 00:04:01,230 --> 00:04:07,740 But remember this key developer fundamental because you're going to need it throughout your career. 51 00:04:08,480 --> 00:04:17,720 By the way, this article over here has some really important points that I think you'll really benefit 52 00:04:17,720 --> 00:04:21,260 from, especially in the commenting best practices. 53 00:04:21,620 --> 00:04:27,620 You can read some of the do's and don'ts and what some of the top programmers do when commenting. 54 00:04:28,100 --> 00:04:35,150 I know it sounds silly, but it is an important concept that most courses overlook, so I highly recommend 55 00:04:35,150 --> 00:04:36,720 you read over this. 56 00:04:36,740 --> 00:04:41,270 I'll link to it in the resources and I'll see you in the next video.