Results 1 to 15 of 15

Thread: Pitfalls of cut and paste coding

Threaded View

  1. #12
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,957

    Re: Pitfalls of cut and paste coding

    It would probably help if the original coder bothered to document their project with comments.
    Pah, comments are for the weak!

    I'm being facetious but, actually, I think there's a serious point to be made: I think over-commenting is as bad as under commenting. When I see things like this:-
    Code:
    'Open the connection
    Connection.Open
    it makes me want to scream. The code in that case was self commenting and the developers comment is just noise.

    Good variable and procedure naming also removes the need for a lot of noisy comments. I also hate this:-
    Code:
    public function Add(int X, int Y)
    'Purpose: To add two integers together
    'Scope: This function is publicly available
    'Developer: FunkyDexter
    'Date: 9 10 2012
       return X + Y
    End Function
    Again, the code was self documenting and the comments are just noise. OK, maybe the developer and date comments are handy from an admin point of view. Also, I guess if you're using a tool that automatically reaps comments from your code to produce documentation then the other comments are useful purely to feed that (although I hate that aproach to documentation on principle - I think it misses the point of documentation) but don't stick that stuff in there and pretend you were trying to help out the next developer because you weren't. What you were doing was feeding an anally retentive compulsion.

    Comments are for when the code isn't obvious. And there will be those times. Mostly they should describe domain context e.g.
    'Apply a 25% uplift to category 5 orders because of the extra workload they entail
    There are also time when you need to explain the use of a technology that's non-standard in the rest of the app.

    Finally, they should NOT be used for this to excuse away a bad design decision in the vain hope that the next developer won't think you were a complete yutz. He'll think that anyway, it's in our nature to assume our predecesser was a pin-headed loon whether he was or not.

    Comments are really important and that's why it's important to use them sensibly. Too much noise stops me from hearing the important stuff.
    Last edited by FunkyDexter; Oct 9th, 2012 at 06:03 AM.
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width