I, for one, would enjoy hearing an explanation. Why is a block form easier to debug than the statement modifier form? What kind of bug is easier to find in one over the other and why? I'd like to see examples and rationales.
The ad hominem attack and unsupported assertions are optional. Include them if they give you comfort, but please include more than that also.
Thanks.
| [reply] |
He didn't say that it made it harder/easier to debug. He started to mention "when you go to add". Adding debugging code is just one reason you might need to add code down the road. Having to do a transformation on the format of the code just to add a line means the code requires more work to maintain. I understand that argument and at least partially agree. If you are strongly stressing maximizing how easy the code is to maintain, then I think that added cost is worth considering.
Of course, it isn't a slam-dunk, obvious "win" in the cost/benefit analysis in all cases. I think it is more likely to be noticed if statement modifiers are just one of many "costly" practices and they are rather heavily used.
Of course, chromatic mentions one way that it actually does make it harder to debug. It can also make it harder to add debugging stuff if you need to add a debugging step that should go between two things that you have done in one line.
| [reply] |
Why is a block form easier to debug than the statement modifier form?
It's often easier to set a line breakpoint in a debugger if there's only one sequence point per line.
Of course, a good debugger gives you more options for setting breakpoints than just "When execution reaches this line," so it's a slight reason.
| [reply] |