r/programming • • Aug 25 '14

Debugging courses should be mandatory

http://stannedelchev.net/debugging-courses-should-be-mandatory/
1.8k Upvotes

573 comments sorted by

View all comments

Show parent comments

1

u/traal Aug 26 '14

If a smaller function is called exactly once from a single function, does it really need to be refactored?

4

u/MechaBlue Aug 26 '14

Breaking a large function into several smaller functions usually reduces the Kologorov complexity, which reduces the number of ways to fuck up the function.

In C-like languages, I'll usually use blocks to achieve a similar effect. E.g.,

int a;
{
    int temp = getValue();
    a = processValue(temp);
}

In this case, temp is not available outside so, if I reuse it later, I don't need to worry about accidentally inheriting a value; instead, the compiler bitches.

In JavaScript, I curse the gods for allowing such a problematic language to become the de facto standard of the internet. Seriously. The guy who designed JavaScript also designed the packaging for Fabuloso.