Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3427790
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:52:48+00:00 2026-05-18T06:52:48+00:00

I am creating function (for example) to validate content, then if it is valid,

  • 0

I am creating function (for example) to validate content, then if it is valid, close the view, if it is not, present further instructions to the user. (Or other such actions.) When I go to name it, I find myself wondering, should I call it -doneButtonPressed or -validateViewRepairAndClose? Would it be better to name the method after what UI action calls it, or name it after what it does? Sometimes it seems simple, things like -save are pretty clear cut, other times, and I can’t thing of a specific example right off, but I know some have seemed like naming them after what they do is just so long and confusing it seems better to just call them xButtonPressed where x is the word on the button.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T06:52:49+00:00Added an answer on May 18, 2026 at 6:52 am

    It’s a huge problem!!! I have lost sleep over this.

    Purely FWIW … my vote is for “theSaveButton” “theButtonAtTheTopRight” “userClickedTheLaunchButton” “doubleClickedOnTheRedBox” and so on.

    Generally we name all those routines that way. However .. often I just have them go straight to another routine “launchTheRocket” “saveAFile” and so on.

    Has this proved useful? It has because often you want to launch the rocket yourself … in that case call the launchTheRocket routine, versus the user pressing the button that then launches the rocket. If you want to launch the rocket yourself, and you call userClickedTheLaunchButton, it does not feel right and looks more confusing in the code. (Are you trying to specifically simulate a press on the screen, or?) Debugging and so on is much easier when they are separate, so you know who called what.

    It has proved slightly useful for example in gathering statistics. The user has requested a rocket launch 198 times, and overall we’ve launched the rocket 273 times.

    Furthermore — this may be the clincher — say from another part of your code you are launching the rocket, using the launch-the-rocket message. It makes it much clearer that you are actually doing that rather than something to do with the button. Conversely the userClickedTheLaunchButton concept could change over time, it might normally launch the rocket but sometimes it might just bring up a message, or who knows what.

    Indeed, clicking the button may also trigger ancillary stuff (perhaps an animation or the like) and that’s the perfect place to do that, inside ‘clickedTheButton’, as well as then calling the gutsy function ‘launchTheRocket’.

    So I actually advocate the third even more ridiculously complicated solution of having separate “userDidThis” functions, and then having separate “startANewGame” functions. Even if that means normally the former does almost nothing, just calling the latter!

    BTW another naming option would be combining the two… “topButtonLaunchesRockets” “glowingCubeConnectsSocialWeb” etc.

    Finally! Don’t forget you might typically set them up as an action, which changes everything stylistically.

    [theYellowButton addTarget:.. action:@selector(launchRockets) ..];
    [theGreenButton addTarget:.. action:@selector(cleanUpSequence) ..];
    [thatAnimatingButtonSallyBuiltForUs addTarget:.. action:@selector(resetAll) ..];
    [redGlowingArea addTarget:.. action:@selector(tryGetRatingOnAppStore) ..];
    

    perhaps that’s the best way, documentarily wise! This is one of the best questions ever asked on SO, thanks!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let say I have the following desire, to simplify the IConvertible's to allow me
I have a new web app that is packaged as a WAR as part
I want the messagebox to only show if the number is equal to 0.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.