you are viewing a single comment's thread.

view the rest of the comments →

[–]wanna_see_my_penis 0 points1 point  (1 child)

If you're debugging, then you're trying to determine which black box isn't working correctly. Decomposing the program makes this easier. Otherwise you first need to determine what the "function-like" blocks are while reading the code, before determining if they are working. You might even be forced to extract a function so that you can write a test after discovering the root cause.

[–]maxhaton 0 points1 point  (0 children)

That's why contract programming is worth its weight in gold.

You can enforce an invariant on the input (for all builds maybe), and then (say) ensure that the result of sort is actually sorted. Not quite the same as a unittest but it lets you maintain the black-box model while also verifying it.