Chuckle of the day:

Chuckle of the day:

const
  CLRF = #13#10;

And it was defined local in multiple methods.

Comments

  1. Someone's right hand is faster than their left? Or did they just want to alternate their use? :-D

    ReplyDelete
  2. Carriage Line Return Feed
    sLineBreak wants to have a word with the programmer.

    ReplyDelete
  3. For me this is not so bad if it not "defined locally in multiple methods".
    Yep -  "sLineBreak" is ok for the people which know about existence this constant but... if you don't know about it's existence? Probably the problem is in the not so good documentation of Delphi and of course in the RTFM (Read The Fucking Manual).

    ReplyDelete
  4. I've seen this in code of highly skilled developers, I've done the mistake many many many times in the past; it's not the end of the world really; IIRC I've seen something like that in JEDI code as well -- could be wrong.

    Anyways, sLineBreak is at least since d7, IIRC it's available even since d5 -- don't quote me on that (:

    ReplyDelete
  5. Nicholas Ring  '#' character is a PITA to type on azerty keyboards (Alt Gr + 3)

    Martin Wienold  be wary of sLineBreak: the platform a text file will be read on is not always the platform it is generated on :)
    So don't go around blindly replacing those CRLF with sLineBreak, you'll regret it.

    ReplyDelete
  6. azerty keyboards are a PITA :p (ok, unless you are french ^^)

    Eric Grange It was for displaying some text in a MessageDlg ;)

    ReplyDelete
  7. Stefan Glienke non-US keyboard are PITAs, including Dutch, German, Belgian, Swiss, UK, etc. Just cannot decide about which is the worst (:

    ReplyDelete
  8. On PC Croatian keyboard is quite tolerable, but on Mac it is just horrible, especially when combined with idiotic Objective-C syntax

    ReplyDelete
  9. Old habits die hard. And some of us were declaring CRLF before Turbo Pascal came along. ;)

    ReplyDelete
  10. In DOS I remember writing a for subroutine called ClearTheScreen that issued a PRINT statement 24 times. When I showed my instructor he said why not just use the CLS statement.  Just saying - "You Don't Know What You Don't Know" :-)

    ReplyDelete
  11. Michael Riley Heh, I spent few hours handcrafting drawing with multiple rotated ellipses in BASIC, and then I discovered for loop three pages later ;-)

    ReplyDelete
  12. At least nowadays we can always google for "How can I do ..." so fortunately there is no need to reinvent things even if you don't know them (yet). And that's also why I tell every new trainee to read at least Classes.pas and SysUtils.pas (and maybe some others like Math, DataUtils, StrUtils, ...).

    Jeroen Wiert Pluimers German keyboard is just fine as long as you write in a language that does not require curly braces. :)

    Btw CRLF: I once did a grep in our source for #13#10 and one for #10#13 and they were quite equally often used. ;)

    ReplyDelete
  13. And frankly, if that were the worst thing I found in legacy code, I would be delighted!

    ReplyDelete
  14. Bill Meyer Believe me there would be enough of much worse to fill thedailywtf for some while. Btw it was more the typo and seeing it multiple times in one unit that made me smile. ;)

    But it shows the basic attitude that I dislike (not just with Delphi developers but they show it often): reinventing the wheel all the time

    ReplyDelete
  15. Stefan Glienke I believe you. I have plenty worse, myself, like multiple occurrences of hard-coded color values in hex--and some in decimal. And export to spreadsheets where columns are referenced only by number--then I get tasked to insert a column....

    ReplyDelete
  16. Stefan Glienke what's so bad about curly braces? They are about as bad to type as the square brackets and backslashes on a German keyboard.
    You either have to contort your right hand or you have to press Alt+Ctrl with the left to reach them. And honestly, I use äöü (especially ü ;) ) more often than the braces.

    ReplyDelete
  17. Lübbe Onken I said if you are using a language that has no begin/end but curly braces. I guess if I would have to type that all day I would learn US layout :)

    ReplyDelete
  18. I'm coding 80% in Delphi, 20% in C#. I don't find it too bad.

    ReplyDelete
  19. Lübbe Onken People are versatile, and can adapt to all sorts of unhappy situations. There are even people who enjoy Lisp!

    ReplyDelete
  20. Now that was my chuckle of the day Bill Meyer

    ReplyDelete
  21. Stefan Glienke  Thank you for the tip. I will be spending my weekend reading. :-) Quote: "And that's also why I tell every new trainee to read at least Classes.pas and SysUtils.pas (and maybe some others like Math, DataUtils, StrUtils, ...)"

    ReplyDelete
  22. Michael Riley for each new Delphi version, i perform a BeyondCompare diff of the sources directory.

    ReplyDelete
  23. Jeroen Wiert Pluimers Smarty Pants. What a great idea. I should have started hanging around with you guys years ago. :-)

    ReplyDelete
  24. Jeroen Wiert Pluimers A trifle problematic, though, when leaping from D2007 to XE5....

    ReplyDelete
  25. Bill Meyer Not really, you just have to preprocess the VCL source to remove the copyright headers and put each version's VCL into a version control system that can detect renames.

    Makes seeing how the source has evolved across various versions trivial when you cram every revision into a private Git/Hg repo.

    I did that once for 2007-XE2. I'd love to have such a repo that spanned all versions and SKUs.

    ReplyDelete
  26. me too. I might one day do it for Delphi 1-current but only the topmost SKU. But it takes a lot of time going through all the updates and hot-fixes.

    ReplyDelete
  27. Michael Riley it helps having a system that has most Delphi versions since 2007 installed (:

    ReplyDelete
  28. I'm just sad that sLineBreak is so poorly named, If they really wanted to make the point they should have called it dLocalisedPlatformSpecificNewLine just so no-one was tempted to actually use it without first defining const NL = dLocalised... Delaing with code that uses that constant a lot gets really tedious quite quickly.

    ReplyDelete
  29. Moz Le I think it's fine as it is if you are using it for GUI things only because then it's correct for the platform you are building for. Of course you should not use it for files that might have different linebreaks that depend on the OS or editor they were created with.

    ReplyDelete
  30. Stefan Glienke the problem is that it adds 10 characters per occurrence, replacing at most two characters. Hence the popularity of CRLF as a better name - 4 characters.

    ReplyDelete

Post a Comment