Singular method name for single object argument, plural for a list?

Posted by nasufara on Stack Overflow See other posts from Stack Overflow or by nasufara
Published on 2010-04-25T03:39:47Z Indexed on 2010/04/25 3:43 UTC
Read the original article Hit count: 235

Filed under:
|
|

I'm having a problem with naming a method for a database application.

In my Database instance, I have a method that can remove an Agreement object from the database. However, I want to be able to remove multiple Agreements at once, to be able to use transactions. The problem is that I also have an overload to remove a single Agreement object.

Essentially, my structure is like this:

public class Database
{
    // ...

    public void RemoveAgreement(Agreement a)
    {
        // ...
    }

    public void RemoveAgreement(IEnumerable<Agreement> agreements)
    {
        // ...
    }
}

But this can be confusing, as the overload with the list of Agreements has a singular name, despite being inherently plural.

My question is, how should I structure this? Should I have two overloads with the name RemoveAgreement(), or RemoveAgreements()? Or should I use two separate methods, instead of overloads?

Thanks.

© Stack Overflow or respective owner

Related posts about best-practices

Related posts about c#