Check your compiler warnings and hints. They may still be errors.

I try to follow a zero hints and warnings policy for my code. (I admit I don’t always succeed though. 😉 ) But I was initially confused on how to solve this, and because of that learned something about not always following directions blindly…

See this example code.

function Test: boolean;
var Something: TSomething;
  Result := false;
  Something := TSomething.Create;
    // Perform something that may raise an exception
    Result := true;
    FreeAndNil (Something);

This function should return true if everything went ok, without exceptions, and false otherwise. You’ve probably at some point written something like that too. However, I get a compiler hint pointing to the first line of the function:

[dcc32] H2077 Value assigned to 'Test' never used.

I can make the hint go away by removing the first Result := false assignment. However, is my Result then guaranteed to initialize to false, as I would like it to? Lees meer over dit bericht

ReSharper Postfix Templates plugin

Developers: ever notice how you often, when typing some piece of code, most often a variable or other class reference, have to track back your keystrokes to surround it or prefix it with something else? The Postfix Templates extension for ReSharper by Alexander Shvedov (@ControlFlow) minimizes the times you have to backtrack what you typed, by enabling you to continue typing and selecting what you actually wanted from intellitype as if it were a virtual extension method, after which the templating engine completes your code including prefixing and surrounding where needed. That may sound difficult as I describe it perhaps, but pictures paint a thousand words: check out the small demonstration videos on the github site, it explains much better than I can. Using it for a couple of days it has already saved me a lot of backspacing and cursor-left presses and it just… feels more intuitive what you are doing.

Lees meer over dit bericht