Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Self documenting code is such a bullshit meme, like sure code itself should also as much self-exploratory as it is possible, but, if needed why not explain it further in comments ? That's the fucking reason comments have been invented after all. If the comment add nothing but bloat, well that's a problem of that particulate comment content not the idea of commenting the code itself.
-
sariel85342yIf you can't understand what the code is doing without comments, maybe you shouldn't touch it?
Comments are supposed to bring clarity to moments in your code.
If your methods or functions are longer than 200 lines, it should be broken up.
There should never be a reason to give a line-by-line description of what your code is doing when it's 200 lines or less. -
sariel85342y@Fast-Nop that's when comments should be used.
But I don't need a comment to tell me what a loop is looping over, the collection name should be named properly to deduce that.
I also don't need a comment to tell me why we're looping over the collection because the method/function name should be descriptive enough to know that.
This is what it means to write self-documenting-code.
Have a complex majestical l mathematical formula that needs explaining? Go for it.
Need to make a note about why this bit of code is important for another system? Brilliant!
Need to explain why the method "displayUsers" is looping through users? Get wrecked.
I cannot stand comments in code, they make it difficult to see what the code is doing. I didn't become a developer to read a fucking book, I became one to read and write code. -
If the architecture is complicated, comments barely help. At that point you need documentation.
Having classes everywhere doesn't itself create a complicated architecture but it sure is possible to create a complicated architecture with classes. -
@electrineer the architecture needs a fucking book, not documentation. like jesus christ - this is hell.
People be like: “We don’t use comments cause good code should explain itself”
Then proceed to use complicated app architectures with classes all over the place.
Fuck.
rant