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



I had much the same feeling as you have Joe. 
 
When Brad said it was 2 programs out of 200 that had not set on LR I
shivered. 2 times out of 200 is probably a mistake. Or is it? I shudder to
think of Brad trying to get that toothpaste back into the tube.
 
---------------------------------------------------------
Booth Martin http://www.MartinVT.com
Booth@xxxxxxxxxxxx
---------------------------------------------------------
 
-------Original Message-------
 
From: RPG programming on the AS400 / iSeries
Date: 11/14/03 09:31:35
To: 'RPG programming on the AS400 / iSeries'
Subject: RE: ARGH!!! (was file open with LR)
 
> From: Buck
>
> > Joe, doesn't one lose the value of reusable code
> > if you can not depend upon it?
>
> Great question! I have strong feelings on this matter so indulge me
for a
> moment.
 
I avoided this conversation because it's highly opinion-oriented, but I
have to at least say my piece here.
 
Reusable code is as close to "the grail" as we can get. The problems
that occur are not because the code is reusable, but because they're
(re)used incorrectly.
 
This is the concept of the "side effect", which is what OO is all about
(removing side effects, accessing logic only through interfaces). In
Brad's case, there was a horrible side effect of calling the program:
namely the file was left open in the default activation group (as close
as I can figure from his posts). This side effect was not documented,
and in fact probably wasn't even considered by the folks who wrote it,
because they didn't think about it.
 
If you write a file I/O routine, you better be damned sure that everyone
who uses it understands the ramifications. Does it open files? Share
them? Position them? Expect the position to stay the same? Typically,
if you write a file I/O routine, you should probably ensure that you
have your own ODP. This would alleviate any side effects such as the
one Brad is seeing. You can do this relatively easily by having an
initialization routine that overrides the file with a SECURE(*YES) and
SHARE(*NO) and then opens the file. If your program, however, counts on
the RPG cycle to open the files, then you need to make sure anyone
calling this knows it.
 
This problem was NOT a failure of the architecture of reusable code, it
was simply a failure of IMPLEMENTING a reusable object, and specifically
of side effects which were not documented and thus not known. This, by
the way, is another reason that I advocate moving ALL file I/O for a
file into a single module; it avoids some of these issues. It sometimes
causes a little extra upfront work, but in the end it makes your life a
lot cleaner.
 
Anywho, don't want to step on toes here, I just want to chime in with my
opinion that the issue was NOT the reusable code at fault - it was the
undocumented side effects which burned Brad's butt.
 
Joe
 

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.