Normally, I try to write the minimal amount of code: e.g. I don’t think you’ll ever see me write NEXT(1) when a simple call to NEXT suffices. In some cases, however, I do write INSERT(FALSE), MODIFY(FALSE) or DELETE(FALSE) in order to show future maintainers of my code that I explicitly chose not to call OnInsert, OnModify or OnDelete (instead of having forgotten to even consider calling the trigger in question).

Makes sense? :)

5 Responses to “Intermezzo: Explicitly calling INSERT(FALSE), MODIFY(FALSE), DELETE(FALSE)”

  1. Natalie Says:

    It absolutely makes sense!
    But it\’s easier for the ones dealing with your code afterwards to know WHY you choose that way.
    So adding a short comment aside would be even nicer.

  2. jhoek Says:

    Hmmm… As much as I hate comments (because they are so often used for the wrong reasons), you may be right…

    Then again, when you write INSERT/MODIFY/DELETE without any parameters, do you normally add a comment explaining why you’re not calling OnInsert/OnModify/OnDelete?

    (Thanks for your response! :) )

  3. kriki Says:

    I hate default values. A lot of times (especially if something doesn’t work and you have to fix it), it is not clear if the programmer forgot to put MODIFY(TRUE) or he meant MODIFY(FALSE). So I use MODIFY(FALSE). (And I also always initialize local variables in functions even if they are initialized by default.

  4. jhoek Says:

    @kriki: We seem to agree about the first point - indicating explicitly if you don’t want to call OnInsert, OnModify etc. :-)

    I’m not sure about the second part, though. When calling e.g. FINDSET, or even NEXT, do you always specify all parameters, even if they have their default value?

  5. kriki Says:

    FINDSET: yes.
    NEXT: I have to admit that I don’t use it in this case, because 99.999% of the time it is the default. And if you don’t use the default and forget to put the value, you see immediately that it doesn’t work (at least if you do a bare minimum of testing your code).

Leave a Reply

*
To prove you're a person (not a spam script), type the security text shown in the picture. Click here to regenerate some new text.
Click to hear an audio file of the anti-spam word