c# generating barcode C++ example of asterisks in pointer declarations. in Visual C#

Encoder EAN / UCC - 13 in Visual C# C++ example of asterisks in pointer declarations.

Listing 31-53. C++ example of asterisks in pointer declarations.
EAN 13 Printer In C#
Using Barcode creation for .NET framework Control to generate, create EAN 13 image in .NET framework applications.
www.OnBarcode.com
EAN / UCC - 13 Reader In C#.NET
Using Barcode scanner for Visual Studio .NET Control to read, scan read, scan image in VS .NET applications.
www.OnBarcode.com
EmployeeList* employees; File* inputFile;
Barcode Creator In C#
Using Barcode creation for .NET framework Control to generate, create barcode image in Visual Studio .NET applications.
www.OnBarcode.com
Recognize Bar Code In C#
Using Barcode reader for .NET Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com
The problem with putting the asterisk next to the type name rather than the variable name is that, when you put more than one declaration on a line, the asterisk will apply only to the first variable even though the visual formatting suggests it applies to all variables on the line. You can avoid this problem by putting the asterisk next to the variable name rather than the type name, as in Listing 31-54:
European Article Number 13 Maker In .NET
Using Barcode printer for ASP.NET Control to generate, create EAN 13 image in ASP.NET applications.
www.OnBarcode.com
EAN13 Generator In .NET
Using Barcode creation for Visual Studio .NET Control to generate, create GTIN - 13 image in .NET framework applications.
www.OnBarcode.com
Listing 31-54. C++ example of using asterisks in pointer declarations.
European Article Number 13 Encoder In Visual Basic .NET
Using Barcode maker for VS .NET Control to generate, create EAN / UCC - 13 image in .NET applications.
www.OnBarcode.com
Paint QR-Code In Visual C#.NET
Using Barcode drawer for .NET Control to generate, create Denso QR Bar Code image in VS .NET applications.
www.OnBarcode.com
EmployeeList *employees; File *inputFile;
Code39 Creator In Visual C#.NET
Using Barcode creation for VS .NET Control to generate, create ANSI/AIM Code 39 image in .NET framework applications.
www.OnBarcode.com
Bar Code Maker In C#.NET
Using Barcode generation for .NET framework Control to generate, create barcode image in VS .NET applications.
www.OnBarcode.com
This approach has the weakness of suggesting that the asterisk is part of the variable name, which it isn t. The variable can be used either with or without the asterisk. The best approach is to declare a type for the pointer and use that instead. An example is shown in Listing 31-55:
Barcode Encoder In C#
Using Barcode creator for .NET framework Control to generate, create barcode image in .NET framework applications.
www.OnBarcode.com
Creating ANSI/AIM Code 93 In Visual C#
Using Barcode maker for .NET Control to generate, create Code 9/3 image in .NET applications.
www.OnBarcode.com
Listing 31-55. C++ example of good uses of a pointer type in declarations.
Barcode Creator In Visual Studio .NET
Using Barcode maker for .NET Control to generate, create bar code image in .NET framework applications.
www.OnBarcode.com
Make PDF 417 In Java
Using Barcode printer for Java Control to generate, create PDF 417 image in Java applications.
www.OnBarcode.com
EmployeeListPointer employees; FilePointer inputFile;
Drawing Code-39 In Visual Studio .NET
Using Barcode generator for VS .NET Control to generate, create Code 39 Extended image in .NET applications.
www.OnBarcode.com
ANSI/AIM Code 39 Generation In None
Using Barcode creator for Microsoft Word Control to generate, create ANSI/AIM Code 39 image in Office Word applications.
www.OnBarcode.com
The particular problem addressed by this approach can be solved either by requiring all pointers to be declared using pointer types, as shown in Listing 31-55, or by requiring no more than one variable declaration per line. Be sure to choose at least one of these solutions!
Code 39 Extended Creator In None
Using Barcode creation for Excel Control to generate, create Code 39 Full ASCII image in Microsoft Excel applications.
www.OnBarcode.com
Code 39 Full ASCII Recognizer In Java
Using Barcode scanner for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
31.6 Laying Out Comments
UCC - 12 Generation In Objective-C
Using Barcode generation for iPhone Control to generate, create EAN / UCC - 13 image in iPhone applications.
www.OnBarcode.com
Code 3 Of 9 Creation In Java
Using Barcode encoder for BIRT reports Control to generate, create Code 3 of 9 image in Eclipse BIRT applications.
www.OnBarcode.com
Comments done well can greatly enhance a program s readability. Comments done poorly can actually hurt it. The layout of comments plays a large role in whether they help or hinder readability.
For details on other aspects of 9 comments, see 32, 0 Self-Documenting Code.
8 CROSS-REFERENCE
de Complete
31. Layout and Style
Page 37
Indent a comment with its corresponding code Visual indentation is a valuable aid to understanding a program s logical structure, and good comments don t interfere with the visual indentation. For example, what is the logical structure of the routine shown in Listing 31-56
Listing 31-56. Visual Basic example of poorly indented comments.
For transactionId = 1 To totalTransactions ' get transaction data GetTransactionType( transactionType ) GetTransactionAmount( transactionAmount ) ' process transaction based on transaction type If transactionType = Transaction_Sale Then AcceptCustomerSale( transactionAmount ) Else If transactionType = Transaction_CustomerReturn Then ' either process return automatically or get manager approval, if required If transactionAmount >= MANAGER_APPROVAL_LEVEL Then ' try to get manager approval and then accept or reject the return ' based on whether approval is granted GetMgrApproval( isTransactionApproved ) If ( isTransactionApproved ) Then AcceptCustomerReturn( transactionAmount ) Else RejectCustomerReturn( transactionAmount ) End If Else ' manager approval not required, so accept return AcceptCustomerReturn( transactionAmount ) End If End If End If Next
6 CODING HORROR
In this example you don t get much of a clue to the logical structure because the comments completely obscure the visual indentation of the code. You might find it hard to believe that anyone ever makes a conscious decision to use such an indentation style, but I ve seen it in professional programs and know of at least one textbook that recommends it. The code shown in Listing 31-57 is exactly the same as in Listing 31-56, except for the indentation of the comments.
de Complete
31. Layout and Style
Page 38
Listing 31-57. Visual Basic example of nicely indented comments.
For transactionId = 1 To totalTransactions ' get transaction data GetTransactionType( transactionType ) GetTransactionAmount( transactionAmount ) ' process transaction based on transaction type If transactionType = Transaction_Sale Then AcceptCustomerSale( transactionAmount ) Else If transactionType = Transaction_CustomerReturn Then ' either process return automatically or get manager approval, if required If transactionAmount >= MANAGER_APPROVAL_LEVEL Then ' try to get manager approval and then accept or reject the return ' based on whether approval is granted GetMgrApproval( isTransactionApproved ) If ( isTransactionApproved ) Then AcceptCustomerReturn( transactionAmount ) Else RejectCustomerReturn( transactionAmount ) End If Else ' manager approval not required, so accept return AcceptCustomerReturn( transactionAmount ) End If End If End If Next
In Listing 31-57, the logical structure is more apparent. One study of the effectiveness of commenting found that the benefit of having comments was not conclusive, and the author speculated that it was because they disrupt visual scanning of the program (Shneiderman 1980). From these examples, it s obvious that the style of commenting strongly influences whether comments are disruptive.
Set off each comment with at least one blank line If someone is trying to get an overview of your program, the most effective way to do it is to read the comments without reading the code. Setting comments off with blank lines helps a reader scan the code. An example is shown in Listing 31-58:
Copyright © OnBarcode.com . All rights reserved.