I have a method, that returns a List of strings. For some reason I do not allow the method to return a List with more than one string in it. Is it better to name such a method GetEntry or GetEntries?
How to name method that can only return one entry. (C#, ASP.NET)
333 Views Asked by AGuyCalledGerald At
3
It's best to make the method return a string rather than a list, but if that is not possible then you should name it so that its name indicates what it does, so
GetEntry
would be better or evenGetSingleEntry
to make it more explicit.Edit As it seems you are not going to necessarily return a list I would just got for
GetEntry
, i would only useGetSingleEntry
if, for whatever reason, you were returning a list which only had a single entry to make that clear to the callers. this would not be necessary if the method only returns a string, so in that caseGetEntry
would be sufficient.