It's not the worst tbh. It looks bad out of context, but given how UDP works, you need some value that represents a specific "connection" to the server.
So what does "magic number" do? Does it cast some magic? Or does it identify a UDP Connection? If the latter, why isn't it named "UDPConnectionID" or something similar? Wouldn't that be much more readable?
Someone who is familiar with UDP would look at this code and know what a "magic number" is, because it's the correct term. UDPConnectionID could actually introduce confusion by creating a new term, rather than using the accepted canonical term for this value.
36
u/Achereto Jun 09 '20
You can find that piece of code here: https://github.com/electronicarts/CnC_Remastered_Collection/blob/master/REDALERT/CONNECT.CPP#L98
Why is it bad?
The comment adds nothing to your code that isn't already explained by the code.
The name "magic number" is a very bad choice since it's not explanatory.
lots of visual noise around the code.