Adding Comments to Source Code in Java
Adding Comments to Source Code Printing QR Code ISO/IEC18004 In Java Using Barcode encoder for Java Control to generate, create Denso QR Bar Code image in Java applications. One of the first attempts at explaining how a program worked was by making the source code more understandable by using high-level languages, like BASIC or Pascal, to create self-documenting code So rather than try to decipher cryptic code like Create Barcode In Java Using Barcode generator for Java Control to generate, create bar code image in Java applications. SECTION data msg db It s alive!! ,0xa; len equ $ - msg
Reading Bar Code In Java Using Barcode decoder for Java Control to read, scan read, scan image in Java applications. Adding Comments to Source Code
Create QR Code 2d Barcode In Visual C# Using Barcode creation for Visual Studio .NET Control to generate, create Denso QR Bar Code image in .NET framework applications. SECTION text global main main: mov eax,4; write system call mov ebx,1 mov ecx,msg mov edx,len int 0x80 mov eax,1 system call mov ebx,0 int 0x80 Denso QR Bar Code Encoder In .NET Framework Using Barcode drawer for VS .NET Control to generate, create QR Code image in .NET framework applications. You could replace the preceding assembly language commands with a shorter, more descriptive high-level language command like this: QR Code ISO/IEC18004 Encoder In VB.NET Using Barcode encoder for .NET framework Control to generate, create QR-Code image in VS .NET applications. PRINT It s alive! Bar Code Printer In Java Using Barcode creation for Java Control to generate, create barcode image in Java applications. Such self-documenting code helps explain what a single line of code does, but doesn t necessarily tell you how the entire program works as a whole or what problem the program even solves Rather than rely on self-explanatory language commands, programmers started adding explanations directly into the source code itself by using comments A comment is nothing more than text, embedded in the source code To keep the compiler from thinking a comment is an actual command, every comment needs a special symbol in front of the comment, such as Create Bar Code In Java Using Barcode generation for Java Control to generate, create bar code image in Java applications. REM This is a comment in BASIC This is another comment in BASIC // This is a comment in C++ and Java # This is a comment in Perl and Python ; This is a comment in LISP and assembly language Make Barcode In Java Using Barcode encoder for Java Control to generate, create bar code image in Java applications. Comments allow you to write short explanations, directly in the source code, that describe what the source code does Looking at the following code, can you understand what it does Making Data Matrix ECC200 In Java Using Barcode creation for Java Control to generate, create DataMatrix image in Java applications. C = SQRT(A * A + B * B) EAN13 Encoder In Java Using Barcode creation for Java Control to generate, create EAN 13 image in Java applications. Deciphering this code is straightforward This command multiplies two variables by themselves, A and B, adds the results together, and finds the square root of the sum, which gets stored in the C variable However, knowing how the command works doesn t tell you what or why this code is doing this By adding comments to the source code, you can explain this, as follows: Printing Leitcode In Java Using Barcode generation for Java Control to generate, create Leitcode image in Java applications. Calculates the hypotenuse of a triangle (C) using the Pythagoras theorem: C2 = A2 + B2 C = SQRT(A * A + B * B) Recognizing EAN-13 In .NET Framework Using Barcode scanner for .NET framework Control to read, scan read, scan image in Visual Studio .NET applications. Adding Comments to Source Code
Generating Bar Code In .NET Using Barcode generation for ASP.NET Control to generate, create barcode image in ASP.NET applications. Even if you don t know (or care) about Pythagoras theorem, the comments help you understand what the command is calculating Some programmers use comments to insert jokes, profanity, or remarks about their co-workers directly in their source code Just be aware that other people besides you may need to look at your source code So if you ve laced your program with profanity-ridden tirades against your co-workers, don t be surprised if one of your co-workers finds and reads the comments you made about him, which could be humorous or embarrassing You can put comments anywhere in a program because the compiler ignores them anyway The two types of comments are line comments and block comments Making Code 128 Code Set A In Visual Basic .NET Using Barcode printer for .NET Control to generate, create Code 128 Code Set C image in VS .NET applications. Book II 9
Data Matrix 2d Barcode Generation In Visual C# Using Barcode printer for Visual Studio .NET Control to generate, create ECC200 image in VS .NET applications. Line comments
Draw European Article Number 13 In Visual Studio .NET Using Barcode creation for .NET framework Control to generate, create EAN / UCC - 13 image in .NET applications. Line comments appear directly on a line that already contains a command like this: Printing Bar Code In .NET Using Barcode generation for VS .NET Control to generate, create bar code image in Visual Studio .NET applications. C = SQRT(A * A + B * B) Calculates Pythagoras theorem
Create GS1-128 In Visual Basic .NET Using Barcode creator for .NET Control to generate, create GS1-128 image in .NET applications. Documenting Your Program
Bar Code Creator In VB.NET Using Barcode creation for .NET framework Control to generate, create barcode image in .NET framework applications. The problem with line comments is that they can make source code somewhat harder to read That s why some programmers prefer putting comments on separate lines like this: Calculates Pythagoras theorem C = SQRT(A * A + B * B) Comments exist purely for other people to read, so it doesn t matter whether you put them on a line with a command or on a separate line To make comments easier to read, use plenty of blank lines and spaces The following example looks crowded: Calculates the hypotenuse of a triangle (C) C = SQRT(A * A + B * B) Calculates Pythagoras theorem By adding blank lines and extra spaces, you can make each comment easier to find and read: Calculates the hypotenuse of a triangle (C) C = SQRT(A * A + B * B) Calculates Pythagoras theorem
|
|
|
|
| ALL RIGHTS RESERVED. Business Refinery (c) 2006 - 2010. | Terms of Use | Privacy Policy |