×
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 Tuesday, February 17, 2004, at 07:57 AM, Bartell, Aaron L. (TC)
wrote:
The first IF statement below will check to see if I want to include
this
record as part of my results. If I don't, it will just get the next
record
from the ResultSet. I am curious as to how you would code this without
using the CONTINUE keyword
I should know better than to enter this discussion but ...
LEAVE and ITER are always conditional operations. That means they can
be removed from code by reversing the test. In your example Java code
the continue can be removed by:
while (rs.next()) {
if (!isNonStoreAccnt(rs.getInt("CORPCONS"), rs.getInt("STORE")))
{ if (firstTime == 'Y') {
...code...
firstTime = 'N';
}
if (rs.getInt("CORPCONS") != savCorpCons) {
...code...
}
if (rs.getInt("DIV") != savDiv
|| rs.getInt("SUBDIV") != savSubDiv
|| rs.getInt("PRDDIV") != savPrdDiv
|| rs.getInt("PRDSUBDIV") != savPrdSubDiv) {
...code...
}
}
} // End While Loop
The only valid argument in favour of continue (or ITER) in the original
construct is that positive tests are easier to grasp than negative
tests. !isNonStoreAccnt is a negative test. I would probably solve that
by providing an isStoreAccnt method rather than the existing negative
method (or create a wrapper method that does the negation).
This is not to say that ITER and LEAVE should never be used, just that
they should be avoided. These operations are similar to GOTO. The
problem is not the GOTO itself, rather it is the lack of a COME-FROM.
GOTO is occasionally useful but like LEAVE and ITER it usually
indicates poor structure. And the less said about the LEAVESR
abomination the better.
Whenever you find yourself coding LEAVE or ITER have a closer look at
the code. In most cases restructuring the existing tests will remove
the need for LEAVE or ITER and simplify the code. If not then use them
but don't use them as a matter of course. THINK about the code you
write.
LEAVE and ITER (and continue and break) make sense particularly when
the code is driven by a state machine but even then are more often an
indication of a language weakness disguised as a feature (e.g., switch)
however use inside I/O loops or conditional tests is usually just
laziness.
Regards,
Simon Coulter.
--------------------------------------------------------------------
FlyByNight Software AS/400 Technical Specialists
http://www.flybynight.com.au/
Phone: +61 3 9419 0175 Mobile: +61 0411 091 400 /"\
Fax: +61 3 9419 0175 \ /
X
ASCII Ribbon campaign against HTML E-Mail / \
--------------------------------------------------------------------
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.