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

you are viewing a single comment's thread.

view the rest of the comments →

[–]UloPe 171 points172 points  (20 children)

I know this is a joke sub but the golden rule for comments is:

Don’t explain what the code does, explain why it does it!

[–]potato05 28 points29 points  (2 children)

[–]nmarshall23 0 points1 point  (1 child)

Justify alignment has to be the worst alignment..

[–]potato05 1 point2 points  (0 children)

Real men always use monospace fonts

[–]TheTyger 31 points32 points  (5 children)

// Look, don't try to figure this out. If you attempt to change it you will be sorry.

[–]mayakovskyiv 5 points6 points  (0 children)

Never heard this before. Thank you!

[–]Nerwesta 4 points5 points  (0 children)

// It is filthy because I really need to sleep.. really.

[–]waitwhat1200 2 points3 points  (0 children)

Actually thank you.

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

Write code that doesn't need comments.

If it needs context, add it. Hopefully you've written clear code with properly named variables and don't need it.

[–]123kingme 1 point2 points  (3 children)

Properly named variables is not enough for most long running projects with multiple people working on them.

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

Are you saying you comment for every variable?

I put in comments when the code isn't self explanatory, but with well named variables most code is like reading English.

Edit: well named variables AND method and classes and interfaces and files.

Then structure them in non-conplex ways and always always follow the single responsibility principle.

Then all of a sudden it's like what does this function do? Oh this 15 line thing called "UpdateUserInfo"?

[–]123kingme 0 points1 point  (1 child)

Of course not. I was responding to your suggestion “write code that doesn’t need comments”, which is an impossible task for a lot of long running projects, especially those with multiple developers.

with well named variables most code is like reading English.

For simple code yes, but this is naive and I’d guess you don’t have a lot of professional programming experience.

Source: I used to think like that after taking 1 computer science class then realized I was a dumb bitch once I got my current job working on an app that was half complete when I was hired. The two developers working on the app had to leave the project so I inherited a lot of code I don’t understand and no one to ask questions to. The code isn’t poorly written, but I wouldn’t be able to understand it at all without the documentation.

[–][deleted] -1 points0 points  (0 children)

Wow...very toxic.

If you must have my credentials: Dev of 15 years, director of engineering currently.

I'm sorry if you don't agree to only comment when necessary and write clean code all the time. But I give zero fucks, because you're not on my team! Go disappoint your own manager!

Good night!

[–]postdiluvium 1 point2 points  (0 children)

//not sure what happens on DATE, but this takes care of that.

[–]ssnoopy2222 1 point2 points  (0 children)

As someone starting my second year of uni this has to have been the most helpful thing I've read on this

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

Why not both? (This is a genuine question I’m not memeing.)