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

Advantages of Routines

The following list summarizes some of the advantages of using routines:

  • Reducing duplicated code

  • Reusing code

  • Simplifying complex code

  • Hiding implementation details

  • Dividing tasks among programmers

  • Making debugging easier

The only major disadvantage to using routines is that doing so adds some overhead to the program. When a piece of code invokes a routine, the program must prepare the routine for execution, and it must store some information so that it can return to the correct location in the code that called the routine after the routine finishes. This overhead is usually small, so it doesn’t cause much of a problem unless a program calls a routine a very large number of times.

For example, suppose that a program contains a loop ...

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