Naming for Performance

One of the not often discussed cause of slow performance is careless naming.

When you are naming a method that does more than get or set some value, try to avoid a name that might mislead the caller into calling it multiple times instead of saving it to a local variable.  For example, if a method is named GetTopicName, the caller is not going to expect it to search for the value and instantiate many objects in the course of doing so.  Instead use a name that implies and warns the caller about the cost of the method, like FindTopicName or CalcPrime.

When using a language that supports properties like C#, try not to turn heavy methods into properties.  Property getters and setters should be light operations.  If you have to, then try to precalculate the value and update on change via event handlers.  Failing that, try to warn the developer using documentation so the developer can use the property accordingly.

One caveat: Guidelines are not meant to be straightjackets.  Don't do it if you can't do it.