Training
Certifications
Books
Special Offers
Community




 
Practical Standards for Microsoft® Visual Basic®
Author James D. Foxall
Pages 400
Disk 1 Companion CD(s)
Level Int/Adv
Published 01/26/2000
ISBN 9780735607330
ISBN-10 0-7356-0733-8
Price(USD) $49.99
To see this book's discounted price, select a reseller below.
 

More Information

About the Book
Table of Contents
Sample Chapter
Index
Related Series
Related Books
About the Author

Support: Book & CD

Rate this book
Barnes Noble Amazon Quantum Books

 

Table of Contents


Acknowledgments xiii
PART 1  Design  
Chapter 1  Introduction to Standards 3
    Why This Book Is Necessary 5
    About This Book 9
Chapter 2  Creating Object and Project Templates 13
    Using Object Templates 14
    Using Project Templates 16
    Exploring Visual Basic Project Templates 16
    Creating Custom Project Templates 17
    Customizing Template Behavior 18
    Enabling and Disabling Templates 19
    Setting the Templates Folder 19
    Directives 20
        2.1 Never hard-code application-specific or component-specific values in object templates. 20
        2.2 Provide extensive comments in object templates, particularly where modifications are required. 23
Chapter 3  Designing Modules and Procedures 25
    Create Modules That Have Strong Cohesion 26
    Create Loosely Coupled, Highly Specialized Procedures 28
    Make All Procedures Perform Specialized Functions 28
    Make Procedures as Self-Contained as Possible 30
    Minimize Fan-In and Fan-Out 31
    Attempt to Alphabetize Procedures Within a Module 32
    Directives 33
        3.1 Give procedures and modules descriptive names. 33
        3.2 Give every procedure a single exit point. 35
        3.3 Give every procedure a clearly defined scope. 39
        3.4 Use parameters to pass data between procedures. 41
        3.5 Call procedures in a consistent and self-documenting manner. 45
PART 2  Conventions  
Chapter 4  Naming Conventions 51
    Data Type Suffixes 52
    Hungarian Notation 52
    Denoting a Variable's Data Type 53
    Denoting a Variable's Scope 55
    Other Prefixes 56
Chapter 5  Using Constants and Enumerations 59
    Using Constants 59
    Magic Numbers Are Prone to Data Entry Problems 60
    Magic Numbers Are Difficult to Update 60
    Constants Make Code Easier to Read 61
    Using Enumerations 61
    Creating Custom Enumerations 62
    Using a Custom Enumeration 63
    Directives 64
        5.1 Prefix all constants with c_ and a scope designator. 64
        5.2 Use constants in place of magic numbers, regardless of scope. 67
        5.3 Use enumerations whenever they are available. 68
        5.4 Use constants when you refer to elements of a control array. 70
        5.5 Use an application or company prefix for enumeration members. 71
        5.6 Use system constants when enumerations aren't available. 73
        5.7 Use an enumeration whenever a parameter accepts a limited number of values. 75
Chapter 6  Variables 79
    Directives 80
        6.1 Define focused variables. 80
        6.2 Give variables descriptive names. 82
        6.3 Use mixed case in variable names. 86
        6.4 Abbreviate only frequently used or long terms. 87
        6.5 Use qualifiers consistently. 88
        6.6 Use the positive form in Boolean variables. 89
        6.7 Explicitly declare variables. 91
        6.8 Declare variables with carefully chosen data types. 94
        6.9 Use the Variant data type only when absolutely necessary. 98
        6.10 Minimize variable scope. 103
        6.11 Concatenate strings by using an ampersand. 106
Chapter 7  Error Handling 109
    Visual Basic's Compilation Options 110
    The Err Object 112
    Types of Error Handlers 113
    Ignoring Errors by Using On Error Resume Next 114
    Diverting the Flow of Execution by Using On Error GoTo 116
    Error Handlers and the Call Stack 122
    Disabling Error Handlers at Run Time by Using On Error GoTo 0 124
    Enabling and Disabling Error Handlers in Debug Mode 125
    Central Error Handlers 127
    Logging Errors to a Text File 130
    Directives 134
        7.1 Use On Error GoTo to trap unexpected errors. 134
        7.2 Use On Error Resume Next to trap expected errors. 136
        7.3 Create consistent error handler blocks. 138
PART 3  Coding Constructs  
Chapter 8  Formatting Code 145
    Directives 150
        8.1 Do not place multiple statements on a single line. 150
        8.2 Use the line continuation character. 151
        8.3 Indent continuation lines. 156
        8.4 Use indentation to show organizational structure. 160
        8.5 Indent code within the Declarations section of a module to show subordination. 168
        8.6 Use white space to group related statements. 169
Chapter 9  Commenting Code 179
    Directives 180
        9.1 Document the purpose of the code. 180
        9.2 If you need to violate good programming style, explain why. 182
        9.3 Document when an error is expected and why. 182
        9.4 Comment before writing code. 184
        9.5 Use solid-character comment lines only for major comments. 185
        9.6 Avoid creating comment boxes. 188
        9.7 Use an apostrophe to denote comments. 189
        9.8 Make your comments readable. 191
        9.9 Indent comments to align them with the statements that follow. 193
        9.10 Give each procedure a comment header. 193
        9.11 Document code processes by using inline comments. 198
        9.12 Use end-of-line comments to document variables. 203
Chapter 10  Looping Structures 205
    Directives 206
        10.1 Use For.Next to loop a specific number of times. 206
        10.2 Use Do.Loop to loop an undetermined number of times. 216
        10.3 Use Do.Loop in place of While.Wend. 223
        10.4 Use For Each.Next to loop through all members of a collection. 223
Chapter 11  Controlling Code Flow 229
    Directives 230
        11.1 Use If.Then.Else when the decision is based on one condition being True or False. 230
        11.2 Use Select Case when comparing a non-Boolean expression to a variety of possible values. 234
        11.3 Use end-of-line comments to add clarity to nested decision structures. 239
        11.4 Format expressions for accurate evaluation and ease of understanding. 241
        11.5 Refrain from using GoSub whenever possible. 243
        11.6 Use GoTo only when there are no other alternatives or when jumping to an error handler or single exit point. 244
PART 4  User Interaction  
Chapter 12  Interface Design 251
    The Necessity of Consistent Interface Design 252
    Directives 254
        12.1 Give forms a consistent appearance and behavior. 254
        12.2 Present controls with a standard appearance. 265
        12.3 Use the best interface component for a given situation. 273
        12.4 Provide comprehensive and sensible menus. 281
        12.5 Use system colors wherever possible. 289
Chapter 13  User Input and Notification 295
    User Input 296
    Notifications 297
    Directives 298
        13.1 Ensure thorough keyboard navigation and interaction. 298
        13.2 Provide consistent and intuitive mouse interaction. 307
        13.3 Create thoughtful and functional message boxes. 318
PART 5  Team Projects  
Chapter 14  Version Control 329
    Directives 330
        14.1 Increment the version number each time you compile a program. 330
        14.2 Display a program's version number in the About dialog box. 332
        14.3 Maintain backward compatibility in ActiveX components. 333
        14.4 Document changes in a Readme file. 341
        14.5 Back up your files. 342
        14.6 Use Microsoft Visual SourceSafe to maintain versions of source code. 343
Chapter 15  Source Code Control 345
    Identifying the Challenges of Team Development 346
    Understanding Visual SourceSafe 347
    Setting Up Visual SourceSafe 348
    Creating a Visual SourceSafe Database 349
    Opening a Visual SourceSafe Database 349
    Adding Users to a Visual SourceSafe Database 351
    Placing a Visual Basic Project Under SourceSafe Control 352
    Visual Basic Projects and Visual SourceSafe 355
    Designating a Working Folder 356
    Creating a Working Copy of the Project 358
    Checking Out Files by Using Visual SourceSafe Explorer 359
    Checking Files In and Out from the Visual Basic IDE 361
    Adding New Files to a Project Under Source Code Control 364
    Getting the Latest Version of Files 365
    Comparing Revisions 367
Index 371


Visit Microsoft Press for more information on
Practical Standards for Microsoft Visual Basic


Top of Page


Last Updated: Saturday, July 7, 2001