I'm 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'm doing this:
public Company GetMonitoredCompany( String companyName ) { ... }
public List<Company> GetMonitoredCompanies( ) { ... }
But I realize that for several times that I use other API's / Services sometimes they have Collection in the name maybe like:
public List<Company> GetMonitoredCompanyCollection( ) { ... }
is there a rule for this? a pattern? or either way should be ok?
Use the shortest, simplest name that clearly shows the methods purpose. And be consistent within your project.
In this example, if there are no other considerations, I would use the name:
GetMonitoredCompanies
Because it's shorter and clearer.
(I would also return a read-only ICollection or IEnumerable unless you've got some specific reason not to.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With