32
beepboop
180d

I just stumbled across this in a code review. Surely I'm missing something here....

Comments
  • 8
    Well I sure am missing the usage of the two to be able to tell if it's alright or not.
  • 3
    @Pyjong var v = Const.Zero -1;
  • 6
    Normally I would say this has been done to apply the clean code paradigm.

    So I'm more than a little disappointed when you presented us the usage.
  • 4
    You're just not smart enough to understand this. Typical at mortal individuals.

    But for real... WTF?
  • 2
    @TylerDDevRant I'm not mad just disappointed
  • 2
    Kinda makes sense for limit tests, where the limits can change randomly.
    Usage in actual production code? nope.
  • 1
    Yeah I wanna know too, is this a test? There must be something behind this. It is more work than just punching in the numbers
  • 2
    @magicMirror but in that case they should be named something like MinLimit, MaxLimit.
  • 1
    @cafecortado thats really for the author to name it. This makes sense too.
  • 1
    @Pyjong it was in a test but was related to number of days in the future.
  • 2
    @cafecortado thats why "kinda makes sense".
  • 2
    @Pyjong if you expect the value to change in the future then you absolutely should not hardcode it imo (only applies to the maxthreedigitnumber var)
  • 2
    @arcsector yeah I agree. Although why not Zero. Base would be more obvious to me by name, but again that's for the author to decide what the name's gonna be.
  • 2
    @Pyjong agreed. The only reason to name it Zero is if you dont expect it to change from Zero... wtffff
  • 1
    is that a COBOL dev? xD
  • 3
    This is absolutely terrible in every conceivable way, because one day someone is going to change it to Zero = 1 and well, do I need to say more? Variables should be named by their function, not their current assignment, even if it is const. I also like my const to be UPPERCASE, but that would (comparatively) be nitpicking in this case.

    But at least you have code reviews.
  • 1
    @saucyatom
    The more you think about it the worse it gets.
  • 2
    The feed did me justice and brought up this again, which I read a few weeks ago. Perfect fit for this rant!
    https://devrant.com/rants/2256386/...

    Edit: Though when I think about it, these are descriptive.. just in a terribly wrong way.
  • 2
    Looks like that was done to eliminate some magic numbers. Naming could've been better though.
  • 1
    If you're running analyzers that check for magic numbers, this was done rather than suppressing the warning.

    If you're not, is there references/pointers to these values? It can be done to ensure you're always getting a reference to the same constant.

    If you're still not, they're stupid.
  • 1
    Still better than

    const THREE = 4;

    Shit interns do, man...
Add Comment