Subroutine - Advantages

Advantages

The advantages of breaking a program into subroutines include:

  • decomposing a complex programming task into simpler steps: this is one of the two main tools of structured programming, along with data structures
  • reducing duplicate code within a program
  • enabling reuse of code across multiple programs
  • dividing a large programming task among various programmers, or various stages of a project
  • hiding implementation details from users of the subroutine
  • improving traceability, i.e. most languages offer ways to obtain the call trace which includes the names of the involved subroutines and perhaps even more information such as file names and line numbers; by not decomposing the code into subroutines, debugging would be impaired severely

Read more about this topic:  Subroutine

Famous quotes containing the word advantages:

    To say that a man is your Friend, means commonly no more than this, that he is not your enemy. Most contemplate only what would be the accidental and trifling advantages of Friendship, as that the Friend can assist in time of need by his substance, or his influence, or his counsel.... Even the utmost goodwill and harmony and practical kindness are not sufficient for Friendship, for Friends do not live in harmony merely, as some say, but in melody.
    Henry David Thoreau (1817–1862)

    No advantages in this world are pure and unmixed.
    David Hume (1711–1776)

    ... is it not clear that to give to such women as desire it and can devote themselves to literary and scientific pursuits all the advantages enjoyed by men of the same class will lessen essentially the number of thoughtless, idle, vain and frivolous women and thus secure the [sic] society the services of those who now hang as dead weight?
    Sarah M. Grimke (1792–1873)