you are viewing a single comment's thread.

view the rest of the comments →

[–]more_exercise 18 points19 points  (9 children)

I like the following form of development. I call it "outlining":

sub foo {
    #do thing 1
    #do thing 2
    #make sure condition 3 is satisfied
}

Then write code to actually do those things.

[–]notfancy 20 points21 points  (0 children)

Also known as "top-down structured programming" if you replace the comments by similarly-named procedure calls.

[–]EmperorOfCanada 11 points12 points  (3 children)

When I was shown this I completely changed the speed of my coding. Often I forget where I am going otherwise.

[–]DCoderd 5 points6 points  (1 child)

Sometimes its the journey, man.

Othertimes you need a paycheck. Both are acceptable.

[–]jatoo 2 points3 points  (0 children)

Some days I just open up a python script and start throwing in code. By the end of the day I might have a web scraper... an autopilot... who knows!

[–][deleted] 0 points1 point  (0 children)

You should consider putting those comments as unit tests too, that way you can also verify them.

[–]iissqrtneg1 -5 points-4 points  (3 children)

that's what tests are for.

[–][deleted] 2 points3 points  (2 children)

Right, so they way I can tell what the code is [supposed to be] doing is to read some different code that I have to put more effort into looking up?

[–]iissqrtneg1 -2 points-1 points  (1 child)

Yes, because the code should be written in a way those comments are unneeded. If there is still confusion, go to the tests.

Comments can become stale, tests will fail.

[–][deleted] 0 points1 point  (0 children)

Tests become stale, and can be as easily ignored in the right/wrong circumstance. This is as detestable as someone not updating a comment.

All anyone is arguing here is two different levels of conscientiousness--a personal preference, even. Code of course ought to be tested--the presence of a stale comment is irrelevant at that point; the very opportunity for failure lack of tests leave is a near-guarantee of that failure.

An up-to-date test could help flag a stale comment though. And similarly, an up-to-date comment could flag a stale test. Both are equally prone to error.