1 00:00:00,270 --> 00:00:01,100 ‫Welcome back. 2 00:00:01,110 --> 00:00:03,920 ‫And this video I would like to cover coding standards. 3 00:00:03,930 --> 00:00:10,140 ‫Basically, coding standards are a set of guidelines, best practices and programming styles that developers 4 00:00:10,140 --> 00:00:13,800 ‫followed when writing source code for a project. 5 00:00:13,800 --> 00:00:19,530 ‫So all big software companies follow these standards and companies have their own standards as well. 6 00:00:19,530 --> 00:00:22,440 ‫So these are just some examples of coding standards. 7 00:00:22,440 --> 00:00:28,620 ‫Of course, once you work in a company, they will tell you to write your code in a certain way because 8 00:00:28,620 --> 00:00:30,030 ‫that's how they do it. 9 00:00:30,510 --> 00:00:33,930 ‫So let's have a look at the parts of the coding standard. 10 00:00:34,860 --> 00:00:38,160 ‫You should always give your variables a reasonable name. 11 00:00:38,160 --> 00:00:43,770 ‫So while declaring a variable, the developer has to give the variable a proper name. 12 00:00:43,860 --> 00:00:46,680 ‫The name of the variable should be based on its use. 13 00:00:46,710 --> 00:00:50,010 ‫Think about what do I use this variable for? 14 00:00:50,010 --> 00:00:55,290 ‫And then give it a name that describes what this variable is really used for. 15 00:00:55,590 --> 00:01:01,320 ‫For example, if you want to store the h of the user, then a good name for that variable would be. 16 00:01:02,060 --> 00:01:04,280 ‫Age or user age. 17 00:01:05,360 --> 00:01:09,020 ‫You should also give your functions a proper name as well. 18 00:01:09,200 --> 00:01:14,390 ‫A function should be given a name based on the functionality it does in the code or program. 19 00:01:14,390 --> 00:01:17,180 ‫So functions usually do actions, right? 20 00:01:17,450 --> 00:01:23,750 ‫So for example, if you want to have a function that will check for internet connectivity, then you 21 00:01:23,750 --> 00:01:26,000 ‫call it check internet connection. 22 00:01:27,550 --> 00:01:28,660 ‫Then comments. 23 00:01:28,690 --> 00:01:34,780 ‫It's a good practice to always leave comments in your code and in big tech companies it's a must. 24 00:01:34,810 --> 00:01:40,390 ‫Functions should have comments which state the use and functionality of that function. 25 00:01:40,540 --> 00:01:46,500 ‫It helps other developers working on the same project to understand what the use of that function is. 26 00:01:46,510 --> 00:01:50,730 ‫And it's not just for other developers, but it's also for yourself. 27 00:01:50,740 --> 00:01:56,050 ‫When you come back to the code a couple of years later or even a couple of months, you will find it 28 00:01:56,050 --> 00:02:01,840 ‫really tough to understand your own code if you don't have proper comments and you will have to figure 29 00:02:01,840 --> 00:02:06,070 ‫out everything from scratch again, which will take way too much time. 30 00:02:06,730 --> 00:02:07,000 ‫All right. 31 00:02:07,000 --> 00:02:10,600 ‫Now let's explore the different types of comments you can use in your projects. 32 00:02:10,600 --> 00:02:15,970 ‫So there are single line comments, and this is a single line comment that you can see here. 33 00:02:16,000 --> 00:02:20,590 ‫It's useful to describe what variables are or what an if statement is for. 34 00:02:20,800 --> 00:02:25,390 ‫Then there are multi line comments used to comment more than one line. 35 00:02:25,570 --> 00:02:30,280 ‫It starts with a slash star and ends with a star slash. 36 00:02:30,280 --> 00:02:33,030 ‫So this can go over multiple lines. 37 00:02:33,040 --> 00:02:38,650 ‫You can add a lot of comments in there and all of that will not be interpreted by the compiler. 38 00:02:38,650 --> 00:02:41,560 ‫So it's just there for the developer to read. 39 00:02:41,980 --> 00:02:48,910 ‫And then you can use the XML documentation comments used to create documentation of functions or a class. 40 00:02:49,030 --> 00:02:51,160 ‫It's a typical type of commenting. 41 00:02:51,160 --> 00:02:58,120 ‫In C-sharp you start with three slashes, then you have the tag summary and the summary is within brackets, 42 00:02:58,180 --> 00:03:02,290 ‫and then you basically just fret whatever this class or function does. 43 00:03:02,680 --> 00:03:08,590 ‫These are pretty useful when you share your code with others because Visual Studio will recognize them 44 00:03:08,590 --> 00:03:11,530 ‫and display the summary when you call the method. 45 00:03:12,280 --> 00:03:18,490 ‫As you can see, once we hover over the methods, we will read the summary we wrote. 46 00:03:18,490 --> 00:03:24,580 ‫So here the cool method, for example, has a summary that says This is a cool method, and once you 47 00:03:24,580 --> 00:03:30,880 ‫hover over the cool method with your mouse, it will state that summary at the bottom of it, saying 48 00:03:30,880 --> 00:03:32,080 ‫what the method does. 49 00:03:32,230 --> 00:03:35,360 ‫All right, so that's it for the standard practices. 50 00:03:35,380 --> 00:03:42,700 ‫Of course, there are more practices that you will come across once you are actually working for a big 51 00:03:42,700 --> 00:03:50,080 ‫firm or in a company in general where you will learn how they decide to, for example, name their variables 52 00:03:50,080 --> 00:03:51,250 ‫and so forth. 53 00:03:51,820 --> 00:03:52,240 ‫Okay. 54 00:03:52,270 --> 00:03:53,770 ‫So see you in the next video.