View previous topic :: View next topic
|
Author |
Message |
jmalli Currently Banned New User
Joined: 19 Jul 2006 Posts: 8
|
|
|
|
Hello Friends.
could you please let me know ,why do we write the sub program ? what are the advantages ? please give me details about it . |
|
Back to top |
|
|
cobolunni
Active User
Joined: 07 Aug 2006 Posts: 127 Location: kerala,india
|
|
|
|
Sub programs are used so that we can easly find the errors in the program
its a common matter a program with 1000 lines of code will be difficult to debug so we are dividing it into some subprograms with 200 or 300 lines so that we can easly identify the errors |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
I find subprograms are a nice way to package functionality into a convenient "black box" for multiple programs to use. |
|
Back to top |
|
|
yaju4ever Warnings : 1 New User
Joined: 30 Sep 2006 Posts: 19 Location: mumbai
|
|
|
|
jmalli wrote: |
Hello Friends.
could you please let me know ,why do we write the sub program ? what are the advantages ? please give me details about it . |
well dear as my knowledge subroutine is used to divide ur large size progrm in to smaller and more manageable parts ..... cobol subroutine is saperatly compiled program.....and when same module is required in more than one applications it may be helpfull to design it in the saperatly compiled program... |
|
Back to top |
|
|
dnreddy
New User
Joined: 08 Dec 2006 Posts: 8 Location: chennai
|
|
|
|
There are several reasons to create subprograms. More than one may apply in a given case.
1) Make Programs Smaller
Traditionally, COBOL programs tend to be large and monolithic. Such big programs are hard to read and harder to maintain. For unusually large load modules, it is useful to break out the major functions into subprograms of a more manageable size.
2) Make Code Reusable
If you find yourself writing the same code more than once, consider burying it in a subprogram, especially if:
? The code is extensive or tricky, or
? There are many potential uses for it.
3) Build Firewalls Around Change
In any application, some parts are are more volatile than others. Consider isolating the most volatile parts in subprograms. Then changes will be easier: first because you only need to change one program, and second because that one program is small and simple. You still need to identify and relink all of the relevant load modules (unless the subprogram is called dynamically), but you would have to do that much anyway. |
|
Back to top |
|
|
|