Most Amazing ReFactor Using ReSharper EAP 5.0 I’ve Seen!

  This one is just to amazing to not blog about.  I’ve been a die heart ReSharper user for quite a while and recently have started using their early access versions.  Primarily because they seem to have added a lot of LINQ support which I use heavily now.  I had the following code before the refactor.  I have to admit, it’s a little .Net 1.1/2.0 ish, but what can I say, I’m a production coder and it did the job. private static int GetTransitTime(string parcelToCheck) { int transitTime = 0; foreach (var parcelSCAC in Constant.UPS_SCAC_MAP) { if (parcelSCAC.Key.Equals(parcelToCheck)) { transitTime = Constant.UPS_TRANSIT_TIME[parcelSCAC.Value]; break; } … Continue Reading

Using ReSharper, I’ve Always Wondered Why They Had the “Invert if” refactor

Well, now I know.  Here is an example of some code I just wrote: if (doDeficitCalc) { throw new ApplicationException("Need to implement deficit weight rating"); } else { // Linear interpolation from top of range to bottom for speed double x1 = rateBreakList[0]; double x2 = rateBreakList[rateBreakList.Count - 1];   double y1 = rateList[0]; double y2 = rateList[rateList.Count - 1];     double frac = weight/(x2 - x1); double yResult = y1 + (frac*(y2 - y1)); retWeight = yResult; } ReSharper correctly warns me that the else statement is redundant as shown below: … Continue Reading

Follow

Get every new post delivered to your Inbox

Join other followers: