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



Hello Joe,

Sorry, I didn't not forget to respond. :-)

On 3/1/2010 7:46 PM, Joe Pluta wrote:
Yet, you still got it wrong. Because clearly the item is valid if it is
found in the ItemMaster. Not that your basic premise is bad; it's just
that there really is no magic bullet.

Yes, you're quite a bit not wrong. :-)

My examples were meant to be:

chain ItemNo ItemMaster;
if not %found;
NotValid = *on;
endif;

. . . 100 lines of code . . .

If (not NotValid);
// use item
endif;


And the simplified example was meant to be:

chain ItemNo ItemMaster;
if not %found;
Valid = *off;
endif;

. . . 100 lines of code . . .

if Valid;
// use item
endif;

Everyone makes mistakes. Please judge the technique based on what I MEANT to say, rather than on my "doh!" silly mistake.


You need to code what makes sense to you, and then secondarily you
need to consider the person who will maintain the code after you.

I completely, 100% agree with you here. And indeed, that was the exact point I was trying to make. The goal is to make the code readable, and in every instance a programmer should be looking to make the code as readable as possible. To yourself first, and secondarily to the person who will maintain the code next.

I think the phrase at the opening of my message ("Sorry, I didn't not forget to respond.") is a perfect example of how extra negatives can make things harder to understand. If I had simply said "I forgot to respond" it'd be easy to tell what I was saying. If I had said "I didn't remember to respond" you'd also have understood -- even though it's negative logic, it's very simple negative logic. But there's a point where it goes beyond that. "I didn't not forget" is beyond that level.

The same is true of computer program logic. The examples in this thread have been simple ones, and therefore easy to understand even though they were negative. But it's possible for it to be too convoluted, and negative logic can be a factor in that.

This was my only point.

FWIW, I disagree with Dennis's statement of "It is considered bad form to use NOT where avoidable". There are times when it can make a statement too convoluted, and there are times when it's perfectly acceptable. The goal should be to make your code as readable as possible, not to make an arbitrary rule of "never do that."

But it's certainly worth considering when writing the statement. Too many people aren't taking the time to think to themselves "Is there a way I can phrase this that will be clearer? Will removing the NOT make it clearer?" And THAT is really what I'm trying to do -- get people to think about it.

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.