Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^4: knowing your audience

by Rhandom (Curate)
on May 09, 2007 at 16:02 UTC ( [id://614427]=note: print w/replies, xml ) Need Help??


in reply to Re^3: knowing your audience
in thread Programming *is* much more than "just writing code".

Yes I did. You never clarified if you replaced the original with your copy.

All of your refactoring and changes void the fixing of the bug in the copy. There is no guarantee that your changes before you even begin working on the bug, don't affect the bug. If you are only using the modified copy to figure out what the original is doing, then you may still be off because there is no guarantee that you refactored the original correctly.

If you are not replacing the original with your modified copy - once you are done with your modified copy, you then have to go through the same exercise on the original because your patches won't apply cleanly.

Either way you have doubled the work that you need to do. In which time you could have instead read the comments and decided if they matched the code.

Should you discard your modified original - you have wasted your employer's time (unless you are the employer). You may now be smarter about the code and have reached a certain nirvana, but you have expended effort on discarded code.

If you don't discard your modified original, then my points still stand.

What you choose to do with your coding practices is entirely up to you. If you feel implied guilt or feel maligned when people post nodes saying "one should comment one's code" and you don't, the issue lies with you. If you are comfortable in your practices that is wonderful -- I am happy for you -- no really, I am. You are under no obligations to anyone who posts or anything posted by other people (I apologize for saying earlier that you are obligated to - thinking about it you really don't have any enforced obligations to anybody - but that is a topic for future nodes). But comments against common practices, that haven't worked for you but do work for many other people, are bound to be ill received -- even when you are right.

my @a=qw(random brilliant braindead); print $a[rand(@a)];

Replies are listed 'Best First'.
Re^5: knowing your audience
by BrowserUk (Patriarch) on May 09, 2007 at 16:38 UTC
    ... read the comments and decided if they matched the code.

    And that's exactly what is wrong with relying upon comments to make your code understandable.

    Comments cannot be tested.

    If I have to mentally run the code in order to decide if (my interpretation of) your comments seems like maybe, could be, if I squint and ignore the typos and grammatical errors and constant changes between first and third person narrative, might actually be correct, then I what? Save myself the effort if having to read the code.

    What else?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      You are right. Comments cannot be tested. So skip the comments. You've still either wasted your employer's time by refactoring everything when you didn't need to (unless your employer intentionally pays you to work the way you do) or you have annoyed your coworkers by making their code conform to your style.

      You are right. Comments cannot be tested. That doesn't mean they cannot be trusted. All of human based language cannot be directly tested by a computer for validity. That doesn't make it less valuable. If this thread really boils down to you not trusting a human developer's comments - that is great - I am sorry for belaboring the issue.

      If grammatical issues are the driving force for this thread, well I can't help you there because my prose and the comments of most other programmers are full of errors. Somehow most people cope. Code often has style or "grammatical" errors that are not syntax errors. Somehow the computer copes as well.

      I do trust comments while I am reviewing somebody else's code for general functionality. I find that when properly done, comments provide a good 30000ft view. If I am doing code review then I look closer and start to evaluate the expressions in context of the comments, but with a little more scrutiny. But when I need to fix a bug I generally ignore comments - not because I don't trust them, but because I have found I can isolate the problem more quickly with other tools and techniques. But I will still be glad when the comments are there because they have previously and will potentially give insight into what some obscure code was intended to do.

      I hate the term "agree to disagree," but I think we must.

      my @a=qw(random brilliant braindead); print $a[rand(@a)];
      And that's exactly what is wrong with relying upon comments to make your code understandable.

      Comments cannot be tested.

      Sure they can. You read them and see if they work, i.e. increase your understanding. If they don't, then you need to fix them -- that's actually part of the job of a maintenance programmer. Though you should probably also ask yourself if they might increase the understanding of someone else working on the code (introspection alone isn't enough).

      (Note that if you're really in the habit of developing patches with copies of code with comments stripped, then when you port your fixes back to the original, there's a real danger that you're going to introduce code that's not in sync with surrounding comments... you're punting on the problem of communicating with future programmers).

        Sure they can. You read them and see if they work, i.e. increase your understanding.

        Hmm. A comment that might increase my understanding when I write it, may not do so for your understanding when you read it.

        It might help Fred, and leave Bill cold, whilst leading Harry right off down the garden path. It all comes back to the imprecision and variablility of interpretation of natural language. And that's before we get into the realms of social and cultural differences.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://614427]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-20 01:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found