10

Unsure , if I should name my variable name as 'info' or 'infoFromDbAboutUser_RequiredForSessionValidation' for a method named 'functionToValidateUserAndCheckSessionIdOrAssignSessionIdIfNotAssigned'

Please help, I am unable to decide. :/

Comments
  • 5
    Make two functions

    checkAuth and checkSession

    And two variable

    userIsAuthenticated and sessionIsValid
  • 1
    SessionToken?
  • 2
    Don't you think your local variable is in a method which is already named properly?????

    In this world you are i and no other world will know about you. Also, in the context of this world , your name "i" fits perfectly. In some other world , some one else will be i
  • 2
    Single responsibility principle.
    Your function is obviously doing more than one thing. The name has an 'and' in it...
    Split the function so each part does exactly one thing. Then your variable names should come naturally. And name your variables on what is in them not for what they're used for (leave the _RequiredForSessionValidation part alone).
  • 1
    Also, welcome to devrant!
  • 2
    Call it john.
  • 1
    @jAsE I need a desktop...with 1 meter display now...if after giving such long names also the purpose of the variable is not defined๐Ÿ˜…
  • 0
    @JackToolsNet thanks for help...but this was just for fun...there is no real function with such name. I just gave this name to convey the struggle we face while naming variable and methods or classnames
  • 1
    @TobyAsE this was just for fun post bro. Anyways thanks for the advice, will definitely remember that.
  • 0
Add Comment