When Not to Refactor

There are situations when refactoring makes less sense than it normally does. One such situation is when refactoring comes at the expense of performance. Contrary to Fowler's otherwise masterful treatment of the subject, I do not believe that refactoring code such that it performs poorly is a good idea, regardless of the frequency with which it is called. In Refactoring, Fowler[13] provides an example in which a temporary variable is eliminated by calling a function repeatedly rather than caching its result. So, rather than having a single call to the function, with its result stored in a variable that is then referenced by the remainder of the method, we have multiple calls. Each time the function's result is needed, the ...

Get Guru's Guide to SQL Server™ Stored Procedures, XML, and HTML, The now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.