tags:

views:

33

answers:

2

hello!

when you start debugging, how do you organize your work? is there any regular actions you take before/while debugging?

in other words what's the best strategy you follow?

thank you

A: 

This basically depends on what your aim is by debugging. Are you fixing some issues check data etc.

But basic thing is to setup a debugger like Visual studio or something which will make your life simpler.

ckv
+3  A: 

My debugging strategy is to write tests so I dont need to use a debugger.

Andrew Bullock
Good luck with that. Unit tests test isolated pieces of code. What happens when you plug in your DB, user input, external services etc?
Jamie
why the downvote? im serious. i have integration tests to cover the db and a stable validation framework covering user input. How can I debug an external service? I'll use fiddler or something to check how it responds. A proper testing strategy has reduced my use of the debugger by 99%. I can't remember the last time I used a debugger for anything serious.
Andrew Bullock
+1 (to counter act downvote). This is indeed the ideal, however I'm far too long in the tooth to live without a debugger :)
Binary Worrier
Because your answer was fundamentally wrong - unit tests won't stop you needing to use a debugger. There is a possibility that some kind of all encompassing unit/integration/functional/regression test suite might reduce the need for debugging, but I've yet to meet a developer who doesn't need to debug every once and a while.
Jamie
i can only speak from experience, and in my line of work having progressed from not testing and using the debugger all the time 3 years ago, to now writing complete unit and acceptance tests, i very very rarely use the debugger and when it do its only to use a Watch. If youve got so much logic in a method that you can't debug it with your brain, its too complicated and you need to refactor. simplicity for the win.
Andrew Bullock
Simplicity is great, small methods are great and full test coverage is great. However when you start using systems with any level of complexity (say, for example, integrating with legacy systems) you realise that your test suites miss that 0.00001% of input that you thought couldn't happen and you need to fire up the debugger. I've reversed my downvote now that you've amended and expanded upon your answer.
Jamie
@Binary thanks. i'm not saying i never use it, but in terms of this guys question which is presumably really asking "im writing buggy code, and want to know how to debug it easily" im saying that writing good unit tests mean you never get into a debug mess in the first place :)
Andrew Bullock