Start Here!™ Fundamentals of Microsoft® .NET Programming by Rod Stephens

Start Here!™ Fundamentals of Microsoft® .NET Programming by Rod Stephens

Author:Rod Stephens [Rod Stephens]
Language: eng
Format: epub
Tags: COMPUTERS / Programming / Microsoft Programming
ISBN: 9780735661660
Publisher: Microsoft Press
Published: 2011-10-05T16:00:00+00:00


Use Descriptive Names

Giving a routine a descriptive name makes it easier for programmers to understand its purpose and to use it correctly. If a routine has a vague name such as DoStuff, programmers will need to look at it more closely to figure out what it does. A programmer who doesn’t correctly figure out the routine’s true purpose may use it incorrectly, creating a bug.

Keep It Short

If a routine is too long, it is hard to see all its code at once and to keep all the routine’s key ideas in mind at the same time. If a routine is long, consider breaking it into several smaller routines that the main routine can call.

Different developers use different rules of thumb for deciding when to break a routine into smaller pieces, but many recommend 100 to 200 lines as a maximum length. Other developers recommend keeping routines to no more than 20 or 30 lines. I prefer to keep routines short enough that I can see all the code and comments in a routine at the same time on the screen.

In general, use as many lines as it takes to perform the routine’s single, well-defined task. If a complex algorithm takes 200 lines to implement and you can’t break it into self-contained parts in a reasonable way, make the routine 200 lines long. It is better to have a slightly longer routine than to break it into pieces that don’t really make sense independently.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.