# Naming of overloaded methods - singular or plural? [closed]

Let's say I have an object Basket that store various items in some private property (Basket._items). Now, I want to have a couple of methods for adding, removing and getting items.

Each method can take either a single item or a list of items as an argument, or with no arguments, in the case of removing and getting, may remove or return all items.

How do you think I should name my methods?

addItem or addItems
removeItem or removeItems
getItem or getItems

(They don't all have to be the same form; for instance, maybe only the last one should be plural.)

-

## closed as off topic by Glenn Rogers, Paul, Brian Reichle, Jeff Vanzella, YannisOct 5 '12 at 20:08

Questions on Code Review Stack Exchange are expected to relate to code review request within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

If the methods add, get and remove multiple items, I'd use a plural. I think it's more obvious that addItems can add one item than addItem can add multiple items.

In any case, good documentation is your ally. :-)

-

Why do you have to use overloading here? I would use both names; the plural for the list, and the singular for the element. Write 6 methods, and be clear about whether you expect an array or element for each.

Also, can a bucket hold anything else? If not, I would prefer the simpler "add", "remove", "list", and "get".

-
Unfortunately, the Basket object does hold other things. I guess using both is an option - but wouldn't you say it goes against the conventions of jQuery, just to give an example? Also, when adhering to the DRY principle, both functions would delegate to the same body of code, which might seem clumsy. –  dalgard Oct 4 '12 at 3:21
Even if you do it in the same method, you will have to branch on list or element somehow, right? Your pluralized method can be very thin, iterating over the list and delegating to the singular method. –  corykendall Oct 4 '12 at 5:35