When to use the word "Plural" or "Collection" in methods

I am creating an API for a module, and after I created several methods inside my classes, I asked myself this question.

Right now, and as an example, I am doing this:

public Company GetMonitoredCompany( String companyName ) { ... }
public List<Company> GetMonitoredCompanies( ) { ... }

But I understand that several times when I use other APIs / Services, sometimes they can have a Collection in the name:

public List<Company> GetMonitoredCompanyCollection( ) { ... }

Is there a rule for this? template? or should it be good anyway?

+3
source share
6 answers

Use the shortest, simplest name that clearly shows the purpose of the method. And be consistent in your project.

, , :

GetMonitoredCompanies

.

( ICollection IEnumerable , , .)

+10

. ... (GetMonitoredCompanies)

+1

(, ..), (GetMonitoredCompanies), . . , , .

+1

, , , . List Get ,

ListMonitoredCompanies

intellisense, , , , .

+1

- , . , . , ? , ( , .., ).

, () .

.

, . ( , , ), FunctionThatLoadsTheTotalFromFileNumberCount (Number), (Count), (Function) , .

0

.NET Framework. . Directory.GetFiles Type.GetMembers . , .

0

All Articles