Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
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. -
Cube18929268yWhat if the implementation suddenly needs to be changed and "stringToLowercase" would have to do something totally different?
-
grasscow2368y@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..
When I saw this code, it is like using 2 pair of chopsticks to eat...
undefined