0

Review some basic concepts in the information technology majors - Part 2: Code, Debug and coding standard (using C# language)

I. Development document

With the development of technology, IDE software is becoming more and more useful and has more tools. Instead of writing the lines of code in the basic program or IDE at the beginning, developers are now looking for the latest IDEs. As I and you, in general, most programmers favored using the IDE as Microsoft Visual Studio to write code for a program. According to Microsoft, their IDE have many features that users need in the same environment, such as the debugger, the compiler, the data file reader, and the archive to a library of saved data, etc.

Solution Explorer: It allows you to manage your scripts, and put them into solution or project files so you can easily manage and arrange your code files.

As shown in the figure, the files are managed and sorted automatically by the Sollution explorer. This tool is visually and scientifically organized but does not lack a file, and is fully automated, the files are stored in it at the same time as you write the program.

Output window:
This is where you manage the output when you start running the program. Here the activity of checking errors in the program will occur. If your program is correct then it will continue to run, otherwise, the program will not be executed, and the window will show where you have errors and need to correct them. This output window makes it faster to find small errors such as form, spelling, punctuation, commas, parenthesis, etc. appearing in the program.

In the above image, the output window appears, in which it declares that the sections you code are wrong, display the line number, and in the wrong place. Very handy and quick in finding and fixing these errors.

IntelliSense: It's a feature that helps you understand more about the type of code you use, or you can write information for your newly created data using the comment "///". Thanks to this feature, the format, setup and usability of the code types are created by the programmer and help the user to easily apply these types of code.

You can write the information yourself for the type of code you declare. As in the picture, I declare the property "Name" and I added information for the property that is "full name of student". When you mouse over the property, it immediately displays all the information I filled in.

Or there are many things that the programmer programmed this IDE has announced when they write.

Squiggles:

is a term, it is the line that has red brick under your feet when you write code. It is intended to alert you that the code is wrong or incomplete and that when you finish the code, it underlines your error. This will help you find the error while you are writing the code, no need to wait until the new program is discovered.

when you write invalid or has errors, it will be displayed the footers like

The Debugger: All IDEs are currently bug fixes. Unlike, this debugger has to run new programs to find, but the errors found are because the program does not produce results with the desired programmer. And even if an exact point is given at the discretion of the programmer, then after being applied and put into use, the user will discover new bugs. And based on the debugger, developers can rebuild or modify code based on code files already available. The tool for finding these errors is most useful in an IDE program because it is the most important part of the process of writing, warranty, and upgrading programs.

II. Debugging

Code and Debugging a basic program tutorial

Normally, a dream program is planned to be programmed according to ideal ideas. But programmers do not work in that environment, and when the program is run, the test starts to show a lot of bugs. These errors start with the inherited code or start from the program you wrote yourself. When the program runs and does not produce the expected results, it is time for errors to appear. Or when the program was run, and the user discovered the bug that the programmer could not predict, it is also a bug. Much of the IDE already has a Debug tool and is used to find and detect errors quickly. That's mostly errors like syntax error, unformatted, non-transferable, etc.

Thanks to the breakpoint tool, programmers can control their Algorithms. If the code is correct, but the result of the program is not what you want, you must use Breakpoint to detect each smaller error. Breakpoints help programmers detect data transmission errors, or help them understand the small steps of the program at runtime, where the data goes, where to go, and where to link, where to take the results. In a program, you can set multiple breakpoints, and when running the program, it will run to the right breakpoint you have set. In addition, the IDE has Step Into, Step Over, Step Out. It's a breakpoint tool, and it also supports you a lot. It displays on the next step-down or step-by-step program, depending on your usage, step by step with each data passed to each given data, and then the next steps. These tools help you control the error and correct them, even if they are errors in data transmission or declaration.

When I wrote the patient management program admitted to the hospital, I encountered many difficulties in managing and arranging the design. A lot of bugs have come up, ranging from declaring, filling information to producing results and completing the program. As you can see in the figure, I have encountered an error in the event programming for the Button Add button. I have set conditions so that when add more patients do not become coincidental because someone may press the ADD button twice. But the error came up, it began to look from the first to the last, whoever did not print it, so many IDs were saved in the patient list. I used the breakpoint tool to run a step-by-step approach to finding this error from the transmission and output of the code. I find the IDE breakpoints useful, as I find that if I find myself in a line of code, analyzing and putting data myself, it takes a lot of time to figure out, or maybe never to find them, etc.

As you can see in the picture, I have intentionally used a breakpoint and I will use “Step” tools to show you what the next step is, how the Breakpoint tool works. When I used the Step tool, the next step, the steps in the small code, breakpoints are displayed on the screen, and the yellow text is the point where the program is running. That is the interface and how the breakpoint and step overwork.

Summary evaluation, when you use it manually to write a program, the number of errors you make is on a non-trivial basis. The error you will encounter will be misspellings, wrong form, wrong data, ..etc. However, most programmers now use IDEs to write code for their dream program. Since all IDEs are now developed, it makes writing programs easier and more convenient. Instead of having to look up every single letter of a word in a code file, thanks to the support tools in the IDE, you write a shorter program, the process of finding the error and fixing it in a snap.

III. Coding standard

The standards of coding in the IDE and in the coding process are generally close to the norm of everything in everyday life. As the name implies, capital letters must be written in the algorithm in the other must be in the "{}" and backward about a cell. Placements are not required but must be relevant to the post so that you can easily reopen and view old posts. The attribute names in the code should also be set according to the purpose you use them for. This is also good for you when you use it during coding. In addition, when writing code, you should write a comment in it. There are two types of comments that use "//" or "///" and their effects are different. The comment in "//" is a comment and does not affect the coding process. It helps you read the code again, so you can quickly understand what you did in the code. Also commented in "///", this comment is largely used to comment on new properties that you declare. It helps you when you reuse these attributes, you can know what these attributes must be filled in, how to use them.

Here is a complete code file, as you can see, the IDE has arranged into the same fields, the files have the same characteristics. In addition, due to coding standards, the data is transmitted and output clearly, parts are independent of each other, and when users use or re-read those lines, it can be quickly In addition, the coding of each programmer helps to create a common language, although reading two different programs, have different uses, but when reading the data reiterated by the previous program, the reader, the translator can understand. With the development of all countries around the world, both economic and social, more algorithms are added, so standardization is a necessity that every programmer must-have.

References: Microsoft Visual Studio


All Rights Reserved

Viblo
Let's register a Viblo Account to get more interesting posts.