Better comment
"adds one to two"
Note that your intended comment isn't quite correct. This can be interpreted as two += one;
, or even two++;
.
A better phrasing would be "adds one and two", which doesn't imply storying the value in two
Better variables
For your intended comment, the confusion mainly stems from you using bad variable names.
one
and two
are incredibly confusing names for integer variables, e.g.
int one = 5;
int two = 88;
Because if we keep applying this approach to naming:
int five = one + two + 2;
int sixteen = 10 + five + one;
int zero = sixteen - 16;
int infinity = five / zero;
What's the value of infinity
?
It's important to note here that if I had used a
, b
, c
, ... variable names, which are meaningless in the current context; you still would have had to do the math, but it would've been less confusing.
Your chosen parameter names add confusion on top of already lacking meaning. That's not good.
This would've been less confusing had you used less ambiguous names:
def foo(number1, number2)
I would also accept def foo(a, b)
if foo
is a mathematical operation.
A direct answer
Is there any industry standard for denoting a variable name in documentation?
Not as far as I'm aware. But when you use good variable names, a comment will generally be understandable:
//Adds number1 and number2
//Returns number2 if number1 is negative. Otherwise, returns number1.
These comments are pretty self explanatory, no? Do you think that wrapping the variable names in delimiters would add something to the comment? Can you give a meaningful example of this?