I'm currently staring in disbelief at the OnCreate of a form that's measuing 684 lines long.

I'm currently staring in disbelief at the OnCreate of a form that's measuing 684 lines long.

What... the...

This shouldn't be allowed. As in, the compiler should not accept this kind of crap.

Comments

  1. What would I give for something like StyleCop for Delphi...

    ReplyDelete
  2. No, no.  You are supposed to cram as much into a single procedure as you can - likewise the shorter the variable names the faster the code runs!

    >_<

    ReplyDelete
  3. Also reusing variables for unrelated purposes is good.

    ReplyDelete
  4. And creating local variables that are used only once is also good.

    ReplyDelete
  5. and no indents at all! f*ck the code formatiing! :)

    ReplyDelete
  6. And lots of nested WITHs - a joy to debug.

    ReplyDelete
  7. Kevin McCoy Oooh...
    with a, b, c do

    ReplyDelete
  8. Bill Meyer and short variable names are much faster to type, never use that boring long names :)

    ReplyDelete
  9. Don't short variable names compile and run faster?  Smaller EXE too.

    ReplyDelete
  10. Have to say, Delphi  QA Metrics have such metrics like Lines of code in method.

    ReplyDelete
  11. Why the hell someone would like to use variables? Just use const with {$J+}!
    And if you have a small part of a unit which is used in more projects, dont extract it to a seperate unit and use it in both. You can use a lot of {$IFDEF ProjectA} and {$IFDEF ProjectB}! Your original code is untouched for compiler and you get only that part that you need!

    ReplyDelete
  12. Fabian S. Biehn Oh, I met one guy who follows your advice about compiler directives. I'm still trying to unsee that code.

    ReplyDelete
  13. Some excellent suggestions here. I'll make sure to mention them at the next team meeting, perhaps we can improve the code further...

    ReplyDelete
  14. Paul Foster
    actually I have run into a problem on some pc's where it turned out to be too long a procedure...the program would lock up..I had to split the procedure into small chunks..curious if anyone else has ever run into that problem...

    ReplyDelete
  15. You should also mix the business logic with states in the display logic, passing objects around using tag fields, etc.  Preferably, you could actually keep all the values in the display object and do logic through there.  Ensures that maintenance fees remain high.  Don't forget to cast pointers to objects!

    ReplyDelete
  16. Inline Assembler, Ladies and Gentlemen, Inline Assembler!
    Cram as much as possible into a single routine instead of splitting it into logical pieces(Pros , might consider writing their whole program in a single Inline-ASM Block, only valid with more than 1000 lines). Comments are for beginners and keep in mind to write only for one specific CPU type. The world doesn't need more than one.

    ReplyDelete
  17. Oh, and when you comment, make sure you comment the how's of each statement as they are seen, and not the higher purpose of the statements and why you do what you do.

    Example: Good commeting

    if Check(value, limit ) // compare value
    then Accept (value) // keep value 
     else Discard(value); // don't keep value

    Example: Bad commeting

    // Only save values that have been validated
    if Check(value, limit )
    then Accept (value)
     else Discard(value);

    ReplyDelete
  18. Try.. Except the whole code to ensure your customer shall not see any errors, even that thing not work.

    ReplyDelete
  19. Try..Except? Really? The Source you write as a total pro is so flawless, you don't even need try...finally
    If something pops up->customsers fault.

    ReplyDelete
  20. Confuse your user in confirmation dialogs.

    "By cancelling, you can avoid this problem. Do you want to avoid?"  
    [Yes] [No] [Cancel]

    ReplyDelete
  21. Seen it, and worse.  I recall a message like:  Do you not want to not cancel dropping this null insertion?

    ReplyDelete
  22. suddenly realised you guys were all taking the mickey :)

    ReplyDelete

Post a Comment