Hacker News new | past | comments | ask | show | jobs | submit login

A question: is really fifth the best ? Seeing FIVE=5 always irks me, as it's an extra indirection for nothing. What do I gain with it ? The ability to change it to FIVE=6 ? OUTPUT=5 maybe but then console.log(OUTPUT) gains you nothing. Maybe NB_LEGS=5 and console.log(NB_LEGS)



This is why I put the word probably in the comment and why I stated that for this particular requirement I actually don't think this is the best approach.

You can always screw around with code, redefining code blocks in C would be fun to do.

But I did have situations where FIVE = 5 changed to FIVE = "five" or FIVE = "5" or FIVE = "vijf" (Dutch) or FIVE = "....." (ok, the last one is hypothetical, but maybe you want five points because you tick them off in a for-loop? I've seen something clever-ish like that in a particular fun Fizz Buzz example).

The layer indirection is indeed a classical trade-off that you do or do not want to make.

Regardless of that, your question proves the point I want to make to kbos87.


Just continuing the discussion, I fully agree with you on principle. I stand by the fact that FIVE is not really a good constant. You will not change five unless you also change the code to handle it, so it just adds another part to modify. And if you never intend to change it or reuse it.. well the only point for making its symbol is to give it meaning, which FIVE does not. But well at a point it's like discussing colours.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: