Re:What should every programmer know about programming?
by varjag on Wednesday September 15, 2010 @05:11PM
(#1695860)
> For debugging it mostly relates to chopping up the program in to bits that are 'verified good' and 'unsure', until you are literally staring at the bug.
It should be noted there's a whole class of bugs where divide and conquer simply doesn't work. E.g. about anything with race condition.
Good points otherwise.
Re:What should every programmer know about programming?
by jacquesm on Wednesday September 15, 2010 @05:14PM
(#1695870)
True enough, and interrupt driven programs tend to exhibit very nasty ones as well where that strategy does not work.
It's not a 100% silver bullet but it will get you quite far.
Re:What should every programmer know about programming?
by achompas on Thursday September 16, 2010 @12:52PM
(#1698331)
Excellent suggestion. This open course lecture from MIT has more, for those who want an example or two:
http://ocw.mit.edu/courses/electrical-engineering-and-comput...
Pick the first half of the two and see if you can solve it.
If not recurse with the first half, else solve it.
Now look at the other half and see if you can solve it.
if not recurse with the second half, otherwise solve it.
For debugging it mostly relates to chopping up the program in to bits that are 'verified good' and 'unsure', until you are literally staring at the bug.
Some sort/search algorithms are an almost literal implementation of divide-and-conquer.
edit: the more I think about this the more I realize that this has pervaded in to just about everything that I do. I'm currently rebuilding a car that has crashed and I find I use divide and conquer to troubleshoot and to repair. Tomorrow I'll be puling the engine to replace a cracked gearbox casing and for sure I'll use it again, both to remove the engine, to remove and replace the gearbox and to put the whole thing back together again, one small 'obvious' step at a time.
edit2: see also: http://news.ycombinator.com/item?id=1695794