Re:Block Comments Are a Bad Idea
by chrismorgan on Wednesday October 11, 2017 @08:19AM
(#15449120)
I view inline comments as a code smell in most languages; I can’t think off-hand of having seen even one occasion where the code couldn’t be tweaked into another nicer form that didn’t depend on inline comments.
[ Parent
| on HN ]
Re:Block Comments Are a Bad Idea
by umbrai_nation on Wednesday October 11, 2017 @08:35AM
(#15449215)
I use them with functions that have too many arguments. It's not always feasible to fix the problem at the source.
damageDealt = calcDamage(weaponType, monsterType, DamageType.FIRE, null /* specialEffectFlags /, false / hasMagicTargeting */ );
It's definitely a code smell, but it's much better than nothing and I'm always glad to see these comments when I come back to the code.
Re:Block Comments Are a Bad Idea
by chrismorgan on Wednesday October 11, 2017 @09:18AM
(#15449457)
Yeah, that was the closest I could think of. But in Python you’d use keyword arguments, and in JavaScript you’d use objects with named fields in lieu of that, and in Rust you’d commonly try to use struct fields or custom enums for such things (I still want named arguments there).
The extreme in your case would be `hasMagicTargeting = false` and then pass `hasMagicTargeting` instead of `false`.