DISQUS

Eddie Awad’s Blog: Comments Do Make a Difference

  • Tim Hall · 3 years ago

    Even better, us a constant with a suitable name :)


    Cheers


    Tim...

  • Eddie Awad · 3 years ago

    Right, constants are very useful in this situation. In fact, I am going to have a separate post about PL/SQL constants soon.

  • Gary · 3 years ago

    Beware of constants as they are really variables (or at least they count as bind variables when it comes to SQL), which means you could end up with some unexpected cursor sharing. [Not saying that it is always bad, just that its something to be aware of.]


    Also, taken to the extreme it just looks silly. I've worked with code that had constants defined for Y and N (eg cv_y := 'Y'). And then you've got to remember whether cv_y is 'y' or 'Y' as the variables are case insensitive.

  • Karl · 3 years ago

    i agree,
    always if possible use constants and as metioned where the optimizer could benefit comment and do not use them.
    Karl

  • Eddie Awad · 3 years ago

    Robert, for some reason, your comment was not posted, however, it was captured in my cocomment. So, here it is:


    Robert Vollman:

    Did you talk to the original programmer? If so, what did s/he say:


    "What are you doing looking at my code?"


    "Oh yeah sorry. No big deal though."


    "I had to get this out the door, no time for comments. Just had to get something working."


    "Comments are a maintenance hassle - if I change the code I have to go change all the comments."


    Nothing, because s/he's long gone.


    Eddie:

    No, I did not talk to the original programmer because he is on vacation. But most likely, he will say one of the things you mentioned, except maybe "What are you doing looking at my code?".


    I have been guilty with leaving off necessary comments before. I believe it is a matter of habit and good practice.

  • Eddie Awad · 3 years ago

    It seems that my spam firewall needs some tuning. Here is Sheeri's comment (lost in spam):


    Sheeri:
    Funny, in my organization there'd be a big ruckus about how it should be scalable, and "magic numbers" like those are often put in a database, so descriptive names and other metadata can be attached. Because there'd be 'make','buy', and then someone would want 'promised', and then someone would want 'almost' ......


    Eddie:
    I do not object to "magic numbers" as long as they are described and documented when used.

  • Jalaj · 2 years ago
    It takes me less time to develop a fresh application than making heavy modifications to old one written by someone else for the same reason. comments do make difference.
  • Kristal L. Rosebrook · 1 year ago
    Interesting Posts
    Kristal