Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
youness22843ycommenting old code and writing new one in case managment change there mind tomorow
Strive for self documenting code. Sometimes that's not possible, for different reasons. Could be time (you need to look for another job), technical reasons etc. Add comments to shed some light on why you did it that way.
The worst thing are comments that doesn't match the code, like refactoring left-overs. No comments are orders of magnitude better than wrong ones.
I write two types of comments, the ones where I am doing something weird but there is a purpose behind it and two the xml crap at the top of a C# method to give some info for intellisense
@undefined I agree that, but the skill of the dev and the focus on making code easy to read is key. Consider this example:
if (a > 3 && b < a)
if ((total > 3) && (average < total))
bool totalValid = ((total > 3) && (average < total));
Adding a properly named boolean makes it much more readable, and removes the need for comments all together.
Yeah, I've read Code Complete :)
Comments for comments sake or because of policy is just wrong. If it is self explaining, why bother?
@dmartin exactly what I do as well.
@uxmedic i agree, naming identifiers with proper names is good practice. Those extra parenthesis does not make it easier to read though. Why explicitly explain precedence? I would look twice and wonder why that was done, and probably conclude the programmer who wrote it does not know the rules of the language.
@undefined Extra parenthesises does in my opinion help clarify code. The example might not be the best one to highlight that. More important in maths to make precedence clear, for instance.
In general I'd say that extra paranthesis are cheap and rarely makes code harder to read. So my take is to be generous with them. 😊
Your Job Suck?
Take a quick quiz from Triplebyte to skip the job search hassles and jump to final interviews at hot tech firms
Get a Better Job