← Back to context

Comment by xorcist

10 hours ago

> They don’t fit on a single screen, so to understand them you end up scrolling up and down.

Split them up into multiple functions and there is more scrolling, and now also jumping around because the functions could be anywhere.

> It’s hard to follow the state, because more things happen

It's easier to follow state, because state is encapsulated in one function, not constantly passed around to multiple.

> a huge switch statement with inline code

Huge switch statements are a common reason for large functions. Python has this architecture and largely won because the interpreter is surprisingly easy to understand and extend.

The need for fuctions are usually abstraction or reusability. If you can extract part of the logic under a nice domain concept please do so. It’s better than comments. Not extracting the logic usually means a lot of intermediate variables to keep track for.

If you are passing your whole state around, that usually means, you’ve not designed your state well.