c# ean 13 check digit Java example of unindented begin-end pairs. in C#

Generation EAN13 in C# Java example of unindented begin-end pairs.

Listing 31-24. Java example of unindented begin-end pairs.
Making GS1 - 13 In Visual C#.NET
Using Barcode generation for .NET Control to generate, create EAN 13 image in VS .NET applications.
www.OnBarcode.com
GTIN - 13 Reader In Visual C#.NET
Using Barcode scanner for .NET framework Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
The begin is aligned with the for. The statements are indented under begin. The end is aligned with the for.
Bar Code Generation In C#.NET
Using Barcode printer for VS .NET Control to generate, create barcode image in VS .NET applications.
www.OnBarcode.com
Scanning Barcode In Visual C#.NET
Using Barcode decoder for .NET framework Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
} for ( int i = 0; i < MAX_LINES; i++ ) { ReadLine( i ); ProcessLine( i );
Create EAN-13 In .NET Framework
Using Barcode encoder for ASP.NET Control to generate, create European Article Number 13 image in ASP.NET applications.
www.OnBarcode.com
Printing EAN13 In .NET Framework
Using Barcode encoder for .NET Control to generate, create EAN13 image in .NET applications.
www.OnBarcode.com
Although this approach looks fine, it violates the Fundamental Theorem of Formatting; it doesn t show the logical structure of the code. Used this way, the begin and end aren t part of the control construct, but they aren t part of the statement(s) after it either. Listing 31-25 is an abstract view of this approach:
EAN 13 Maker In VB.NET
Using Barcode drawer for .NET framework Control to generate, create EAN-13 image in .NET applications.
www.OnBarcode.com
EAN / UCC - 13 Encoder In C#
Using Barcode creation for .NET framework Control to generate, create EAN13 image in .NET applications.
www.OnBarcode.com
Listing 31-25. Abstract example of misleading indentation.
Encode QR Code JIS X 0510 In Visual C#.NET
Using Barcode generator for Visual Studio .NET Control to generate, create QR Code image in .NET framework applications.
www.OnBarcode.com
Linear Barcode Generator In C#.NET
Using Barcode printer for .NET Control to generate, create 1D image in VS .NET applications.
www.OnBarcode.com
A B C D E
Matrix Barcode Maker In Visual C#
Using Barcode encoder for Visual Studio .NET Control to generate, create Matrix 2D Barcode image in .NET framework applications.
www.OnBarcode.com
Leitcode Generator In C#.NET
Using Barcode generator for .NET framework Control to generate, create Leitcode image in .NET framework applications.
www.OnBarcode.com
In this example, is statement B subordinate to statement A It doesn t look like part of statement A, and it doesn t look as if it s subordinate to it either. If you have used this approach, change to one of the two layout styles described earlier, and your formatting will be more consistent.
Bar Code Reader In .NET Framework
Using Barcode Control SDK for ASP.NET Control to generate, create, read, scan barcode image in ASP.NET applications.
www.OnBarcode.com
Code 128 Code Set B Generation In Java
Using Barcode generation for Java Control to generate, create Code 128 Code Set C image in Java applications.
www.OnBarcode.com
Avoid double indentation with begin and end A corollary to the rule against nonindented begin-end pairs is the rule against doubly indented begin-end pairs. In this style, shown in Listing 31-26, begin and end are indented and the statements they enclose are indented again:
Print Quick Response Code In Java
Using Barcode encoder for Java Control to generate, create QR image in Java applications.
www.OnBarcode.com
Making Quick Response Code In Java
Using Barcode creation for Android Control to generate, create QR Code 2d barcode image in Android applications.
www.OnBarcode.com
Listing 31-26. Java example of inappropriate double indentation of begin-end block.
UPC-A Supplement 5 Creator In .NET
Using Barcode printer for ASP.NET Control to generate, create UPC Symbol image in ASP.NET applications.
www.OnBarcode.com
Generating Data Matrix 2d Barcode In VS .NET
Using Barcode creator for .NET framework Control to generate, create Data Matrix ECC200 image in .NET framework applications.
www.OnBarcode.com
for ( int i = 0; i < MAX_LINES; i++ ) { ReadLine( i ); ProcessLine( i ); }
Code-128 Generator In Objective-C
Using Barcode creation for iPhone Control to generate, create Code 128 Code Set A image in iPhone applications.
www.OnBarcode.com
Encoding EAN / UCC - 13 In Java
Using Barcode encoder for Android Control to generate, create EAN 13 image in Android applications.
www.OnBarcode.com
5 CODING HORROR
6 The statements below the begin are indented as if they were subordinate to it.
This is another example of a style that looks fine but violates the Fundamental Theorem of Formatting. One study showed no difference in comprehension between programs that are singly indented and programs that are doubly indented (Miaria et al. 1983), but this style doesn t accurately show the logical structure
de Complete
31. Layout and Style
Page 20
of the program; ReadLine() and ProcessLine() are shown as if they are logically subordinate to the begin-end pair, and they aren t. The approach also exaggerates the complexity of a program s logical structure. Which of the structures shown in Listing 31-27 and Listing 31-28 looks more complicated
Listing 31-27. Abstract Structure 1.
Listing 31-28. Abstract Structure 2.
Both are abstract representations of the structure of the for loop. Abstract Structure 1 looks more complicated even though it represents the same code as Abstract Structure 2. If you were to nest statements to two or three levels, double indentation would give you four or six levels of indentation. The layout that resulted would look more complicated than the actual code would be. Avoid the problem by using pure-block emulation or by using begin and end as block boundaries and aligning begin and end with the statements they enclose.
Other Considerations
Although indentation of blocks is the major issue in formatting control structures, you ll run into a few other kinds of issues. Here are some more guidelines:
Use blank lines between paragraphs Some blocks of code aren t demarcated with begin-end pairs. A logical block a group of statements that belong together should be treated the way paragraphs in English are. Separate them from each other with blank lines. Listing 31-29 shows an example of paragraphs that should be separated.
Listing 31-29. C++ example of code that should be grouped and separated.
cursor.start = startingScanLine; cursor.end = endingScanLine; = editWindow.dimensions; window.title = editWindow.title; window.dimensions window.foregroundColor = userPreferences.foregroundColor;
de Complete
31. Layout and Style
Page 21
cursor.blinkRate SaveCursor( cursor ); SetCursor( cursor );
= editMode.blinkRate;
window.backgroundColor = userPreferences.backgroundColor;
7 CROSS-REFERENCE
If you use the Pseudocode Programming Process, your blocks of code will be separated automatically. For details, see 9, The Pseudocode Programming Process.
This code looks all right, but blank lines would improve it in two ways. First, when you have a group of statements that don t have to be executed in any particular order, it s tempting to lump them all together this way. You don t need to further refine the statement order for the computer, but human readers appreciate more clues about which statements need to be performed in a specific order and which statements are just along for the ride. The discipline of putting blank lines throughout a program makes you think harder about which statements really belong together. The revised fragment in Listing 31-30 shows how this collection should really be organized.
Copyright © OnBarcode.com . All rights reserved.