Next in the series of plaintive Delphi cries, one to (some of) the *users* of Delphi

To many of the Delphi developers I have encountered:

Please memorise the following: Format
Compare:
Message := 'There are ' + IntToStr(numBunnies) + ' bunnies in the forest.' + #13 + 'That comes to ' + FloatToStrF(bunnyDensity, ffFixed, 4, 2) + 'bunnies per acre.';
vs

Message := Format('There are %d bunnies in the forest.%cThat comes to %2.2f bunnies per acre.',[numBunnies, #13, bunnyDensity]);
See how much prettier that is? Please start using it. I beg of you.

Also, consider:
function FunctionNamedFoo: Boolean;
a function which returns a value. You can either place the return value of the function into the keyword variable Result or into the locally-scoped variable FunctionNamedFoo. As you write more and more functions, please decide on the style you prefer and stick to it. Please.

I personally prefer the FunctionNamedFoo approach, since it makes searching the source code much easier. My despair on this issue is however so great that I no longer care which you choose, as long as you choose but one.

Delphi developers I have encountered: Thank you for listening.
Everyone else: My apologies. I do feel better now though.

2 Comments

Filed under delphi, Uncategorized

2 Responses to Next in the series of plaintive Delphi cries, one to (some of) the *users* of Delphi

  1. I’d forgotten there wasn’t a way to get newlines into string literals in a sane way. On the bright side… um… hmm. There *must* be a bright side somewhere. If I think of one, I’ll point it out.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.