× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



fkany=xyKOxUUvAoHhjpcFh+TbANBPR1lH4CV8@public.gmane.org wrote:
Hi everyone,

I've been trying to figure out the difference between an RPG subprocedure
and an RPG program.    So far, I don't see much of a difference on how they
take in data, process the data and send it back.  Lets say I have a
subprocedure that converts an incoming date format to another date format.
Someone could also write a small program that does the same thing.  Why
would a programmer choose writing a subprocedure over writing a program?  I
hope I'm not asking too silly of a question.  Thanks for all your help.
Everyone has been offering some good answers already, but I'll just
add my own two cents worth:

At a high level of abstraction, yes, they are quite the same. They
are both means of splitting an application into more meaningful
chunks of code. In OPM, applications are split up into programs. In
ILE (like practically all other OS environments), applications can
be split up into programs and service programs, which themselves can
be split up into modules consisting of procedures. Designing how you
split up the responibilities into these various pieces can be one of
the trickiest aspects of software development.

At a lower level, there are some functional differences between
programs and procedures. Both accept parameters by address (by CONST
or by reference). But procedures also accept parameters passed by
VALUE, and can return values.

Also, as others have pointed out, there are performance differences
between calling programs and procedures. Generally, since the
address of a procedure is known at bind time, procedure calls are
much faster.

As a rough rule of thumb, use procedures as your primary mechanism
for decomposing your application. Use programs for separate tasks,
and use service programs for procedures commonly used by a number of
programs.

Cheers!  Hans





As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.