Because of this, I write more comments than I feel necessary in Elixir as well: I am proficient in it but many of the readers of my code might not be. Comments don't hurt so don't be cheap with them 
-
-
Show this threadThanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
I once got told to remove my comments in a code review back when I worked with JavaScript, the reason: the code should be self-explanatory. A part of me died that day.
-
IMO try not to comment the ‘what’ unless the code is hard to understand (maybe work more on it, m extract something out). But do comment the ‘why’. Ex this annoys me a little: // adds one to i i+=2
-
I think blatantly obvious comments annoy everybody—especially when they are wrong. I like to comment algorithms…because I want to be able to read it three months later; and also edge cases get a comment because they might seem weird at a first glance.
-
this is a good summary. Obvious is bad in most cases. Commenting the why of code, algorithms, domain knowledge, edge cases, "hacks", is fundamental to write understandable and maintenable software in my opinion.
End of conversation
New conversation -
-
-
Do you write any doctests in addition to or instead of documentation?
-
doctests and documentantion have little to do with comments. Comments are aimed at explaining how code works and why it works that way, documentation is there for telling folks how to use a piece of code. Doctests are documentation tested for correctness. Does it make sense?
End of conversation
New conversation -
-
-
I tend to use comments sparingly, and only when I have done something unusual for a very specific purpose which would not be readily apparent.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Instead of comments why not add a doctest. A comment that can fail if the code changes.
@Adkron#justathought -
I tend to keep my comments in my commit messages because they change when the code changes. If commit messages were useful more people would look there any way. Doctests are a great alternative but don’t say everything that is often needed.
End of conversation
New conversation -
-
-
Will agree to disagree. If it needs a comment, it should be a well-named function, even if (especially if?) it's an elegant, single-line solution like a .Net linq statement.
-
Then write a test for it and confirm the naming is correct.
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.