The 7 Worst Verbs Programmers Use In Function Calls

Here are the candidates for the top 7 worst verbs used in function names. I don’t know if programmers invented these, but whoever did was one evil dude.

#7 – dispatch
The best of the worst is ‘dispatch’. Sometimes it might have a real meaning, but unfortunately you get to see this term used badly in code (where you ‘dispatch’ whatever to wherever). Dispatch can be bit meaningless, but I’ll admit sometimes it might do fine.

#6 – do
Whenever I see a function named “doUpdateSomething” (instead of just “updateSomething”) or “doCompression” (instead of “compress”) I grin.

In a bad way.

#5 – resolve
Another “generic” term for something. Instead of “setConnectionBetweenThingOneAndStuffTwo” some programmers say “resolveConnection”. Looks perhaps cool, but name is meaningless.

Sigh.

#4 – handle
Similar to ‘resolve’ (or to ‘do’). Generic, meaningless word.

#3 – manage
When I see this used in “manageArrays” or something similar it hurts my stomach.

#2 – perform
Another horrible term. Thank god you don’t see this often, but even seeing it once is too much. Why say “performCompression” when you can simply say “compress”?

#1 – populate
The most horrible and worst function name ever.

If class has member function ‘populate’ whadda heck do you expect it to do? From the dictionary you can see that ‘populate’ is defined as follows: ‘To supply with inhabitants, as by colonization; people’

Are you supplying your classes with inhabitants?

P.S. These of courses are final truths and should be accepted without questioning, but since some people refuse to do that then you can alternatively stick to using some of this stuff but also think if you currently code using some generic verbs that have very little meaning.

28 thoughts on “The 7 Worst Verbs Programmers Use In Function Calls

  1. Aperage

    hey,
    nice feedback for beginner…
    to be honest, having english as a secondary language, I do use these terms quite a bit while coding. It’s meaningful to me but reading this post, I understand it’s kind of wrong.

    But could you try, on the contrary, to supply a list of meaningfull function name.
    Mainly like verb examples to enrich people vocabulary and thus improving the code written everywhere

    thank and good luck

    Reply
  2. Kimo

    Loved the article. Gave me something to think about. It takes a lot of work for me to come up with method names so I just call all methods DaKine. As in DaKine01() does does some dispatching, Dakine02() does some populating, DaKine03() does some handling, etc. Saves me a lot of time thinking up new names.

    Reply
  3. Nathan Schubkegel

    While trolling some of my old code, I found a function name that successfully conveyed to me that it may or may not perform an action. It was named UnhighlightAndEndAnyClickAndDrag(). I can’t wait to slip “Any” in front of the noun part of more of my function names!

    Reply
  4. Nathan Schubkegel

    How many people hate the “Check” verb? Often I run into trouble finding a name for a new method that *maybe* does something. I consider using a name like CheckForStateChanges(), but it doesn’t say what the function actually does if it encounters a state change! (My name is purposely generic – real world names would read like CheckForChangedFiles(), CheckInboxForNewMail(), or even terser like CheckValues(), CheckScreenWidth(), etc… and just go home if the context is such that Checkboxes might be involved…)

    One solution would be to put two verbs in the function name. However, this leads me to make methods with unapprovable long names like CheckForUpdatesAndDownloadAndInstall() or CheckValuesAndComplainAboutErrors(). For some reason people hate reading more than 1 verb, 1 noun, and 1 adjective in a single method call. Conjunctions and articles are snubbed too, so these examples were doomed from the start.

    Sometimes I give in, and I steal “good” verbs that have their own valid uses, and I cripple my function names with them. GetNewMail() – it looks like a getter that returns some private instance data, but it actually goes out on the internet and might not return for 15 seconds! CreateErrorReport() – it looks like it’s going to make an error report, but nobody told you it was going to show it AND dispose it when finished! SaveDocumentChanges() – it looks like it’s going to pillage your hard drive by overwriting the whole file every time it’s called! Names that abuse standard-verbs are misleading and I hate them more than full-looking-but-actually-empty candy wrappers on public sidewalks.

    In practice I use Juuso’s lame verbs with enough extra words to accomplish two goals. I provide a name that is memorable – my readers should only need to learn my code once. Then, in that name I give readers a feel for what the function does, but only enough so that they’ll go look at the implementation for confirmation. You can probably imagine what ProcessChangedScreenSize() or PerformErrorChecking() does… but you should really go look to make sure.

    I’d love to hear if anyone developing software at a corporation with peer-reviewed code gets away with names that use “Check” or multi-verbs or hijacked-established verbs. I’d also love to hear about more possible ways to name complicated functions.

    Reply
  5. Chris

    I agree with everything except ‘handle’. Events need to be handles. A common action in search programs is creating the SQL clauses for certain aspects of the search. Those aspects are ‘handled’ by their own blocks of code.

    Reply
  6. Eirik Hoem

    This article would make much more sense if you renamed it to “The 7 Worst Verbs Programmers Use As Function Call Names”. Most of the verbs you describe here works very well IN a function name as long as the rest of the name is describing. On their own they are pretty much useless as you point out :)

    Reply
  7. Rui Ferreira

    I don’t agree with most your

    # dispatch
    I guess that’s one of those words that comes from patterns language. It’s not very descriptive but everyone knows what you’re talking about when you say “dispatched that request to a thread”.

    # resolve
    Resolve domain to ip addr. translate. etc.

    # handle
    Usually used to “handle” events. Handler for double-click, interrupt and so on

    # populate
    It’s used quite a lot, especially in tests. It means exactly that, populate with content….

    Reply
  8. Lumooja

    I use PopulateWorld() to populate the world with content (loading scene from disk, creating lights, setting up physics objects, etc…).
    I agree that other verbs are not so good though.

    Reply
  9. Ryan Fox

    I think “populate” is fine. For instance, one populates an array by filling it with values. Perhaps it’s my terrible theory of mind, but I can’t see anyone being terribly confused by this.

    Reply
  10. Jake Birkett

    @Juuso: basically it’s a wrapper function so your code doesn’t need to call MyObject.ReceiveInput followed by MyObject.Animate and possibly some other third function. I like wrapper functions with simple names so I don’t need to remember to call lots of long-winded named functions. Agreed that it’s better to have Manage() call other functions with clear names that can be seen at a glance rather than having a whole load of code that must be interpreted (of course a couple of comments at the top might be fine…) although I don’t always do this, ahem ;-)

    Reply
  11. Juuso Hietalahti Post author

    Jake: yeh, I know. Sometimes you might need to have “update” (or “manage”) to do several things… It might not be always possible to avoid these type of “general terms”.

    Couple of questions:
    - should it handle animations? (or should animations be handled by some other method?)

    - does the button->manage method call other methods (like “button->receiveInput” and after that “button->animate”)? If so, then it can be pretty clear since at least you can see “what methods manage calls”.

    Reply
  12. Juuso Hietalahti Post author

    Sargon: without knowing anything about your game code structure, but something like this came to my mind: (I’m sure expert programmers can think of better names & ways to call :))

    I would name “MazePopulate” class to “MazePopulator” class, if I were to keep that class. I’m not sure but I think it could be the Maze class’s job to do the populate, so instead of having MazePopulator class you could simply put that “populating thing” (=creating objects) to be member variable of the Maze. (Not sure if this works in your game structure, and it might be wise to keep them separate).

    Here’s my 5 cents (in this example, I use “Level” class as the “Maze” class, and I’ve put “populate” stuff inside the Level class).


    Level class (or alternatively Maze class – if they are the same thing. I’d prefer using Level instead of Maze, IF they are the same thing…)

    - when creating a new level, you could call the “create” (=populate) functions:
    … createWallsAndWhatnotStaticObjectsThereAreMkay?(…)
    … createMonsters(…)
    ………… depending on the level, this could then call “create new Monster” and “create 76 bigMonsters” etc.
    … createItems(…)
    … createOtherStuff(…)

    Monster class
    BigMonster class
    TinyMonster class etc.
    Item class
    OtherStuff class

    —- could this type of approach work? Or make any sense?

    Without seeing your code it’s bit hard to make a guess :)

    Anyway, the bottom line is that since you are doing “inhabiting” with that populate function, I see no problem there.

    Reply
  13. Jake Birkett

    The thing is that if it’s called ManageInput and then it manages anims too then the ManageInput label is no longer accurate, hence my simpler Manage. It called be called ManageAll ;-)

    Reply
  14. Juuso Hietalahti Post author

    Jake: how about…. having “MyButton.receiveInput” or “MyButton.manageInput”… ? ;)

    and how about having another function for “MyButton.updateAnimations” (which could be called from manageInput)?

    While it’s obvious to you… it wasn’t clear to me what manage does (until you said “receive input”)

    Just my 2 cents.
    :)

    Reply
  15. Jake Birkett

    I think Manage is fine. Most of my classes have a Manage function and it seems pretty obvious to me e.g. MyButton.Manage or Menu.Manage or ListBox.Manage. It basically means receive input and process and also deal with any other ongoing stuff (anims etc).

    Reply
  16. Sargon

    I will look in my code how exactly I named it.
    Well, I have a class called MazePopulate, and that class points to a class called MonsterPopulate.
    And I have a method in the maze class called CreateMonster.
    I needed a MazePopulate, because it doesn’t only populate monsters, it also populates items and other stuff. But maybe it doesn’t make sense to use populate on items?
    And the MonsterPopulate class is needed because each level different monsters might be populate, and its convinient to have a different class for each level.
    Anyway, I feel pretty comfortable with the names I gave, they are not too long, and I can tell what the class do from looking at it. At most cases.
    Though giving good names that others can understand as well, is pretty tough.

    Reply
  17. Juuso Hietalahti Post author

    Sargon: The populate in your system sounds fine. If it would be possible to have populateMazeWithMonsters() (or if you have “maze->populate($monsters)”) then I think it’s readable to others as well. If you merely have “populate”, then it’s hard for me to understand that it means you are “populating maze with monsters”.

    It will be hard for you to after 6 months without touching that part of the code ;)

    can you give some other examples too? Would be like to see if we can come up with better function naming…

    Reply
  18. Sargon

    How much consistent is it?
    I think people (programmers) should understand that they cannot create the perfect code.
    There is an informal part in programming.
    You can make as much formal steps as you can make, but eventually you will have to make some informal steps.
    If we could have named our classes and method according to a consistent scheme, then we could have automated this process.
    Why should I think myself of a name for a class if a computer can do it for me?
    Well, its impossible(maybe in the seen future), because choosing names for classes and methods is mostly an informal process that cannot be automated.

    Reply
  19. desertdweller

    So true. I don’t precede my function names with those either, so I can often guess my functions when I need them, because I use a consistent naming scheme.

    It’s a nightmare trying to wade through someone else’s source though.

    Reply
  20. Toni Mäkinen

    Hey, I have update functions. For every class, so by naming my classes right I know what’s happening.

    NPCs->update();

    And inside that it updates all positions, rotations. Simple as PI

    Reply
  21. Sargon

    Heh, I use handle, but mostly in a very basic class that allot of other classes inherit from and implement handle. So handle is kind of generic.
    I also use PhysicManager. And use populate, but I use it to really populate my maze with monsters(and items). So I am not sure to what other meaning of populate you meant.

    But all this is not coincidence.
    One of the principal laws of spartan programming is the principal of the Babylon tower.
    It means that every hierarchy collapse after three or four levels.
    What does that mean?
    It means the language has a limitation in providing us terminology.
    It means that something that have more than four levels of hierarchy, will suffer from having insufficient terms. Because this is the limitation of our minds capabilities to understand, and also of our language ability to describe.

    Bottom line, in a large program, it is very likely that we will have insufficient terms to describe all our classes.

    Reply

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Pro-Human Quiz: