Skip to content

Latest commit

 

History

History
27 lines (19 loc) · 807 Bytes

GCop207.md

File metadata and controls

27 lines (19 loc) · 807 Bytes

GCop 207

"The logic seems extensive. Rename the method to imply this. E.g: Calculate, Find, Select, Create, Evaluate, etc"

Rule description

For historic reasons, a method named GetXyz() can be perceived as something that’s simple and can run quickly. As a result, developers may call it liberally and multiple times (for example in loops or Linq methods).

When your method’s implementation contains substantial logic, you should name the method in a way to bring this to the attention of the callers, for instance to allow them to run it once and store the result in a variable.

Example

protected string GetImage(int imageID)
{
    //more than 25 statements
}

should be 🡻

protected string FindImage(int imageID)
{
    //more than 25 statements
}