A case where named constants are not needed over magic numbers
<p>Obviously the point of using named constants over magic numbers is for code clarity and for not having to go through code changing numbers throughout.</p>

<p>However, what do you do if you just have a number used just once in a function? Say you have a short member function that uses an object's velocity (which we'll say won't change) to calculate its motion, but this is the only function that uses that velocity. Would you...</p>

<p>A) Give the class a named static constant to use</p>

<p>B) Put a named constant in the function</p>

<p>C) Use the magic number but comment it</p>

<p>D) Other...</p>

<p>I am kind of leaning towards using a magic number and commenting it if the number is ONLY BEING USED ONCE, but I'd like to hear others' thoughts.</p>

<p>Edit: Does putting a named constant in a function called many times and assigning to it have performance implications? If it does I guess the best approach would be to put the constant in a namespace or make it a class variable, etc.</p>
