39

When I saw this code, it is like using 2 pair of chopsticks to eat...

Comments
  • 0
  • 0
    @GitP4tt lol who even wrote something like that
  • 2
    Guess somebody really don't like downcase and decided it should be *more* expressive
  • 5
    It might not be dumb at all. There can be couple of reasons to do such a thing. I can think about two of them
    1. Legacy code (backward compability) - maybe a few years ago there was no such metod and someone had to do this manually and now it's just 'left to be' because no one wants to find references.
    2. This might be a backbone for future functionality - look at the comment - in a few days it might be changed to throw an exception when string is not an email.
  • 0
    @grasscow Good sir, is this VSCode you are editing in?
  • 0
    What if the implementation suddenly needs to be changed and "stringToLowercase" would have to do something totally different?
  • 0
    @bryan003 that code is found in an an existing rails 5 project
    @MaLin223 For 1, it is not a legacy code, my coworker created it just yesterday in a rails 5 project. For 2, I agree that it can be backbone for future, but my coworker already applied this in all controller classes and exceptions are not handled, so I really cannot see the reason why we can't use downcase directly except he wants to be more well organized..
  • 0
    Can't your coworker just use alias_method if he really likes the camelcase?
  • 0
    @setyadi he doesn't know what is alias method...**
Add Comment