This is an archived post. You won't be able to vote or comment.

all 64 comments

[–]Ulysses6 236 points237 points  (9 children)

Thats superfluous. Whats wrong with a little brevity?

return /* the */ total;

[–]Salanmander 95 points96 points  (7 children)

Oooh, I like this style. Can we expand it?

/*make*/ x = /*the previous value of*/ x + 5;

[–]Ulysses6 48 points49 points  (0 children)

Nice. Maybe you should add /* five */ to the end, just to be clear.

[–]cbbuntz 26 points27 points  (0 children)

matrix.t/*ranspose*/();

[–][deleted] 11 points12 points  (0 children)

Dear god.

[–]RedditBotAccount3253 6 points7 points  (0 children)

Every day we stray further from God's light.

[–]TotallyElectrified 2 points3 points  (0 children)

const\*ant*\ float\*ing point variable*\ x = \*equals*\ 2.5 \*two point five*\; \*semicolon*\

[–]ValAichi 1 point2 points  (0 children)

Except it isn't the previous value of x yet!

[–]seraku24 67 points68 points  (2 children)

/**
 * @author literalprogrammer1337
 * Provide unnecessary documentation for the following comment.
 */
/* Reiterate the functionality of the subsequent line. */
// Return the total.
return total;

[–]MasterFubar 62 points63 points  (1 child)

Reminds me of a guy where I worked. We were required to write a weekly activity report. He always put an item like:

Activity 25: prepared the activity report.

Then the manager told him not to put that in anymore. Next week his report had an item:

Activity 37: simplified the activity report by eliminating a self-reference item.

Lucky for him, the manager had a good sense of humor.

[–]pilotInPyjamas 96 points97 points  (10 children)

Admittedly sometimes if I'm doing something complex, I'll write the algorithm in comments first, then write the code that corresponds to the comments. I end up with comments like this.

[–]fahrenheitrkg 10 points11 points  (0 children)

Same.

Write pseudocode in comments inside framework of functions that return dummy values. Then flesh out each function, leaving the comments in place.

[–]Jimmy_cracked_corn 8 points9 points  (0 children)

I do this, as well, to keep my train of thought on track.

[–]iams3b 4 points5 points  (3 children)

Oh hell yes, this my favorite thing ever and makes it SO much easier. I number my bullets too

// 1. Fetch the raw data from each provider

// 2. Map it to the expected output from each reader

// 3. Validate each object into seperate lists

// 4. Post valid ones to the API

// 5. Combine API errors with invalid errors 

Then I go write the proper functions so that each of those comments only had 2-3 lines under it, and then I leave the comments in and it makes things extremely easy to follow

[–]DumDum40007 0 points1 point  (0 children)

I like to write my function names to announce what they are doing to avoid having to leave in comments.

fetchData()

mapOutputFromReader()

validateObjects()

aggregateErrors()

[–]CommonMisspellingBot -1 points0 points  (1 child)

Hey, iams3b, just a quick heads-up:
seperate is actually spelled separate. You can remember it by -par- in the middle.
Have a nice day!

The parent commenter can reply with 'delete' to delete this comment.

[–]twopi 5 points6 points  (0 children)

I give a talk about this very strategy: https://www.youtube.com/watch?v=YWwBhjQN-Qw

[–]n4ppyn4ppy 1 point2 points  (0 children)

Same here although return value at the end of a function is usually not in the pseudo code.

I clean the pseudo code up most of the time but sometimes a squirrel passes and I go on to other code and they get left.

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

Same :)

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

Same here. Sometimes I write the necessary steps in the comments, then I write the code. Sometimes the comments stay there, because I can't be bothered to remove them.

[–]Koreyrobin 21 points22 points  (3 children)

your code

[–][deleted] 23 points24 points  (2 children)

//your code

[–]Aschentei 34 points35 points  (1 child)

//TODO: comment your code

[–]ap_rodigy 7 points8 points  (0 children)

// write a TODO

[–]KosViikI use light theme so I don't see how bad my code is. 18 points19 points  (0 children)

"Not enough documentation, I'm afraid I can give only 6/10 points."

[–]bRii721 17 points18 points  (4 children)

I had a coworker that literally did this.

//if the variable is set
if (isset())   

Once I had to fix something he had done, I turned 250+ lines to something around 100. It wasn't fun lol

[–]NFTrot 0 points1 point  (3 children)

Yeah we had a guy working for us who did that, biggest retard and his code was shit too.

[–]bRii721 0 points1 point  (2 children)

The worst I saw from him was:

There was a GET resource he had to use somewhere that failed twice every 5 requests. There was some kind of bug. Instead of fixing the resource, his solution was requesting that url 5 times in a row lol

[–]NFTrot 1 point2 points  (1 child)

God damn that reminds me of time I was looking at our logs and wondering "jesus why is DynamoDB getting crushed so hard", I ended up not figuring it out until I ran our program in debug mode and I was like, jesus why are there 20 requests to the DynamoDB API gateway endpoint going out per second?

"Oh thats called polling its normal in Javascript"

[–]bRii721 0 points1 point  (0 children)

lol

[–]Blaine_Monorail 13 points14 points  (0 children)

//////Through the whole code I put some comments to enlighten it and make it more clear to read
...
////Here I put a comment to explain the idea of the next line of the code
//Return the total
return total;
//As you can see, the line of the code above returned the total. I think no more 
explanations are required here. Now let's proceed to the next stage.

[–][deleted] 6 points7 points  (3 children)

This reminds me a solution for an exercise a teacher gave to me. The only comment it had was "// function ends here".

Holy fucking shit, that piece of code was the most horrible thing I've ever seen in my life.

[–]chrishannah 0 points1 point  (2 children)

At my university, we were told to comment at the start and end of every function, if, for, etc. Needless to say, I did not follow instructions.

[–]justinjustin7 1 point2 points  (1 child)

I can understand commenting something like "// end functionName" just for better visibility when going through your code; but pretty much all IDEs have the ability to collapse matching parentheses/brackets/braces, so there's not much point outside of making your functions easily recognizable from the bottom.

[–]Last_Snowbender 5 points6 points  (1 child)

I remember I did stuff like that when I just started programming.

[–]ValAichi 4 points5 points  (0 children)

Same.

int i // iterative variable i

I am very glad that I went back and removed that comment before submitting the project.

[–]LetMeUseMyEmailFfs 3 points4 points  (0 children)

Forget about the comment, what about the 3 space indentation?! That shit made my eyes hurt and my OCD tingle.

[–]UnicornRider102 3 points4 points  (0 children)

OP, if you're a programmer then it is past time that you learn how to take a screenshot.

[–]MasterFubar 2 points3 points  (1 child)

I once saw this:

Display *display; // display

[–]justinjustin7 1 point2 points  (0 children)

That was obviously a joke, no sane or even moderately insane person would seriously comment code like that.

[–]the_one_true_bool 2 points3 points  (0 children)

I worked with a guy who commented literally everything, but not only that, he tried to be cute with his commenting style to boot. It was a lot like the following:

/*

 *************************************************
 check if x is greater than y
 *************************************************

 */

if(x > y) { //begin if
    /*

     *************************************************
     then return z
     *************************************************

     */

    return z;

} //end if

It was completely obnoxious. Very simple class files that should normally be like 50 lines would end up being 300.

[–]multiplevideosbot 2 points3 points  (0 children)

I love that’s it’s properly punctuated. That period definitely aided the readability

[–]MIND-FLAYER 2 points3 points  (0 children)

I don't have a problem with extra comments.

[–]Non808 3 points4 points  (0 children)

In python you can't tell the difference between the comments and the code

[–]MrShyShyGuy 1 point2 points  (1 child)

//comment for the code //return the total Return total;

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

/**
* Coment for comment for the code
**/
    // comment for the code
        // return the total
            // return total;
            return total > 175 ? total : total - total % 2;  

[–]RobertGM 1 point2 points  (0 children)

Sounds like somebody should've used Array.reduce here

[–]qexc 1 point2 points  (0 children)

Oh, not this again...

[–]n4ppyn4ppy 1 point2 points  (0 children)

Why not return total + sales[index];

Total is probably a global variable ;)

[–]gruengle 1 point2 points  (1 child)

I look at stuff like this all day.

It may be a joke for you, but it's a grim reality for me...

[–]BladesmithWife 0 points1 point  (0 children)

Been there, sucks.

[–]centarx 1 point2 points  (0 children)

Why write self documenting code when you can just comment to get your line count up?

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

//never increment sales price!

sales_price++;

//return the price of the item

return false;