3 ms·
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 anothe
by chrismorgan 9y ago
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.
- umbrai_nation 9y agoI 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.
- chrismorgan 9y agoYeah, 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`.