F5 considered harmful

While reading this publicized blog from Somasegar, in which he tells us that the famous "Edit & Continue" from VB 6 will work in VS 2005 with VB.NET *and also* with C#, I remembered something I read many years ago (I paraphrase because I can't remember yesterday mails, let alone an article I read in 198x):

One of the best lessons I learnt from my first boss was: "when your code doesn't behave as expected, don't use the debugger, think."

Debugging a thousand lines program going step by step is painfully counter-productive yet, for some reason, every body executes his code in Visual Studio hitting F5 and then steps through it until it blows at line 987... IMHO, it's better to hit Ctrl-F5 (which also runs faster), read the exception and the line number, look at the ceiling and ask "why?", because if you don't understand why a program does what it does, you can hardly solve the problem: F5 may help you to patch the line but it won't help you to understand the problem, F5 bloats your code with if's for what you think are "special cases". I won't lie: I use F5 almost every day: when I don't understand why, that is, when I have tried three times to solve the problem and I simply can't get it, but in truth, 80% of the time the problem surrenders to my Ctrl-F5 before I surrender to F5. As an aside, I get a better understandement of the code, and so do other people, because I've got less "special cases".

6 Comments

  • People used to say the same thing about Intellisense. Bottom line - if it allows developers to be more productive, then it is a good thing. As with any tool, there will always be idiots who try to use it *instead* of thinking, but those people should be flipping hamburgers anyway so it doesn't really matter :)

  • Hi Addy,



    I don't think "debug by default" is in the same league as Intellisense. Intellisense saves you from memorizing exact spelling, order and type of parameters, and the like. So Intellisense is basically a superb cheat sheet (a good thing since school days ;-). F5 on the other hand tries to save you from thinking and understanding which most of the times is a dangerous thing *not* to do.

  • There's always one that just doesn't get it! E&C is fantastic.

  • Serio, Edgar, es muy necesario. Imaginate restart una aplicacion de 15 assemblies.

    ---------------------------

    Really, is very necessary. Imagine restart debugging for an application with 15 assemblies.

  • Yes, that's one viewpoint, but...

    Please permit me to perform a febrile, childish dance of victory:



    La la la dee da!

    Edit & Continue!

    Dum de dum de dum de dum

    Will be supported in C#/VS2005!



    Thankyou.


Comments have been disabled for this content.