Why all the constants? I would rather treat a boolean and a function returning a boolean the same way when it comes to naming. In other words, instead of naming the function validateUserNameLength() I would name the it isUserNameLengthValid() or something similar. That would allow me to just go
if(!isUserNameLengthValid(userName)return
and skip all the constants.
And if you want to be really idiomatic about things just create a UserName type that has a function called hasValidLength(). That would allow you to write:
if(!userName.hasValidLength())return
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Why all the constants? I would rather treat a boolean and a function returning a boolean the same way when it comes to naming. In other words, instead of naming the function
validateUserNameLength()
I would name the itisUserNameLengthValid()
or something similar. That would allow me to just goand skip all the constants.
And if you want to be really idiomatic about things just create a
UserName
type that has a function calledhasValidLength()
. That would allow you to write: