6
xsid
5y

What's is more appropriate name for a method?

IsUserExists
DoesUserExist

Comments
  • 6
    Does makes more sense imo
  • 31
    Would probably have skipped both and just used UserExists.

    If(UserExists)

    Reads better tbh. Otherwise does.
  • 10
    I personally follow those rules:
    consistency > case > grammar

    So DoesUserExist, only and only if the rest of your code follows the same pattern.
  • 8
    I'm with @biglars: UserExists
  • 6
    IsUseistDoes, waste more time.
  • 5
    I like forming method names as direct questions, so I'd use UserExists.
  • 16
    UHazUser
  • 3
    @biglars it won't be much readable if I just return and don't use it in IF condition.
  • 4
    @xsid return object.UserExists

    I think it's readable especially if it's a boolean.
  • 2
    IsUserCreated; //if it is about creation a user
    IsUserAvailable; //If about doing stuff when the use is there

    IsUserRecordFound // If it is about databases
  • 3
    I just create a exist() method in user object 🤔
    If(User.exist())
  • 0
    It's based on consistency and constructs of the team. We have a lot of times where we use IsActive, IsAdmin, etc. If we were to introduce a new Boolean to check if a user exists, we would prefer to use IsUserExist to keep the naming consistent.
  • 4
    @irby Adding 'is' to a getter for a boolean is redundant, just drop it. Here it is also confusing as it contradicts the natural language.

    If you wanna be sure that it's a boolean, your IDE will show you.
  • 3
    This is a good example of why it is bullshit to have "is" in the beginning of a bool variable or method or whatever.

    I hate this convention/rule/requirement.
  • 0
    What about isExistingUser?
  • 1
    IsUserCreated
    IsUserInitialized
    IsUserExistent
  • 1
    @Commodore <—— what this guy said
  • 0
    The first one sounds like OG meme talk like "can i haz cheeseburger"
  • 0
    `thing.userExists(user)`

    Or

    `user.exists()`
  • 1
    @ojrask if it's something linked I'd prefer hasUser() or has(userObject)
  • 1
    @Lyniven true, makes more sense.
  • 0
    @Lyniven

    I'd have had assumed this would be in a service or something. Why would you have a User object if you don't know if the user exists?
  • 0
    Fuck a function and method tbh.
  • 1
    @Superviral Care to expand?
  • 4
    UserIsAHumanBeingWhoAppearsInRealWorld
  • 0
  • 0
    I would do something like userExists
  • 0
    isExistingUser
  • 2
  • 0
    @delegate212 The user class not the object here sorry.
    With model relation, if you have a comment with an user_id, the Comment.user() method will receive the user_id and do the query, it'll then check if the returned stuff is an *instance of* the given user class.
    Dunno if I'm clear x) that's my way of doing stuff
  • 4
    TheCreatureWhoTakesAdvantageOfThisProductIsAHumanBeingWhoSeemsToBeVisiblyPresentAmongUsInThisPhysicalUniverseWeAllAreSimultaneouslyExperiencingAndParticipatingIn
  • 0
    UserCommitedExistance
  • 1
    How the fuck is this still going..
Add Comment