× 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.



On 5/15/2017 3:24 PM, Booth Martin wrote:
Why would one use a service program instead of a stand-alone program?

In my opinion, 'Service Program' is an unfortunate choice of
nomenclature. A service program is a collection of sub-procedures, and
not really a program at all. Distant cousins.

That only changes the question to 'why would I use a sub-procedure
instead of a program?' Why, indeed? The quick answer comes down to how
you want to answer this question:

What is the appropriately-sized bit of code to handle Task X?
Some examples might help.

If you wanted to produce an Aged Trial Balance, would you write:
a) A subroutine
b) A sub-procedure
c) A program

If you wanted to convert Fahrenheit to Celsius?
What if you wanted that temperature conversion to go into 10 programs?
Would you write a subroutine and /COPY it in so that you could reuse the
code?

There's no particular answer that is absolutely wrong in and of itself.
It's a matter of how you want to structure your system. My personal
rule of thumb:
Decompose the business problem into small functions.
Write one sub-procedure for each function.
Some will answer a question (what is this customer's email?)
Some will perform an action (delete this customer from and email list)
Once the functions are written and tested, assemble them into the
programs that need them.
Almost all of my sub-procedures go into a service program. That does
two things for my thinking:
1) It forces me to think about parameters, return values, and error
handling and reporting. Because I don't know who will be calling that
function in the future, so I tend to bake that in now.
2) It lets me easily make changes after deployment. When I need to
add one more error handling bit, I rebind the service program and every
caller gets the new copy. ish, but it's pretty close to that simple.

I still use subroutines on rare occasions, but when I do it's pretty
much a flag to myself that I haven't decomposed the problem properly
yet, and I still need to use global variables because of my incomplete
analysis.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.