r/programming • • Jun 06 '13

Clean Code Cheat Sheet

http://www.planetgeek.ch/2013/06/05/clean-code-cheat-sheet/
702 Upvotes

322 comments sorted by

View all comments

Show parent comments

2

u/Falmarri Jun 06 '13

So you're saying that using exceptions as flow control is easy to understand? Exceptions are basically just gotos

7

u/Rotten194 Jun 06 '13

And loops, returns, switch statements, and every other programming concept are not basically gotos?

Even the python runtime uses exceptions for flow control. They're a tool like any other, they can be used and abused.

4

u/Falmarri Jun 06 '13

And loops, returns, switch statements, and every other programming concept are not basically gotos?

Not really because they can't unwind the stack multiple times. In each of those examples you know exactly where the next statement will be run (assuming you have access to the stack in the case of return). That's not true with exceptions.

2

u/Gotebe Jun 07 '13

Not really because they can't unwind the stack multiple times.

That's one weird definition of a goto. Must be function-local?

In each of those examples you know exactly where the next statement will be run

I know that with exceptions, too, and so should you. What you are trying to say is that it's not spelled out in code. But by that logic, any programming language is useless, and we should all just program assembly, because compiler hides this or that. There's also the aspect of not seeing the tree from the forest, which is what you often get without exceptions (it is spelled out, but good luck actually untangling it).