O'Reilly logo

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

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Writing Good Routines

The following list summarizes some of the rules you should follow to make routines as useful as possible:

  • Perform a single, well-defined task

  • Avoid side effects

  • Use descriptive names

  • Keep it short

  • Use comments

The following sections describe these concepts.

Perform a Single, Well-Defined Task

If a routine performs a single, well-defined task, it is easy for programmers to understand what it does and use it correctly. If a routine performs more than one task, programmers may be unable to perform one of the tasks without performing the other. They also may confuse the tasks and not use them properly.

If a piece of code performs multiple unrelated tasks, break it into separate routines, each of which will perform a single task. The code ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required