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



From: David Foxwell

But I need some more arguments.

David, the whole concept of using data structures as parameters is not
inherently a bad one. In fact, it's used quite regularly by APIs in most
operating systems. The biggest benefit is that the data structure is
typically language independent: you have binary fields for numbers and
character fields for strings and just about any language can set up
contiguous chunks of data for these sorts of things.

The other nice thing is that they tend to reduce the complexity of transport
when you have to move data from one operating environment to another (either
via a queuing mechanism or a communications protocol such as HTTP).

So, I use data structures all the time, but typically only if I am either
crossing a language boundary (such as from Java to an ILE language) or when
I am sending data from one machine to another or from one process to another
on the same machine.

Because other than that, all of the issues Scott brings up come into play,
the most important of which to my mind is the loss of prototyping. I think
prototyping (and even more importantly the ability to tell the compiler to
convert between types for you) is a very powerful feature of ILE RPG. It
removes a lot of EVAL statements and even a lot of work variables.

I do have one caveat about the whole optional parameter issue, though, that
data structures does get around. While optional parameters are a seemingly
good thing, the problem is that typically as a function gets past a certain
level of complexity, the permutations of optional parameters gets to be
quite large and unwieldy, and you can end up with lots of *OMITs in your
procedure calls.

Not only that, but if you add all new parameters to the end of your
parameter list, parameters that relate to one another won't remain grouped
together. For example, you might have three groups of parameters, one
required and two optional. The required parameters go first followed by the
two groups of optional parameters. If you're adding a parameter to the
required parameters, where do you add it? At the end of the list of
parameters? If so, then it no longer sits with the other required
parameters (and it suddenly requires a whole bunch of *OMITs on every call
that uses that parameter).

On the other hand, if you put it at the end of the required parameters but
before the optional parameters, then you have to modify every call to the
procedure, which is even more work than a simple recompile.

Whereas, with a data structure you can add the parameter wherever you want
and just recompile everything. Only the programs that need that parameter
will fill it in, and nobody cares about where the parameters are. And for
those that are truly worried about not passing the right parameter
structure, you can include a constant in the data structure that identifies
the version of the data structure and have the called procedure check that
constant -- in that case, the called procedure can even support multiple
versions of callers by reformatting old versions to the new version.

The point is that it's not always a simple black/white proposition. You
have to carefully weigh your business needs.

Joe



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.