Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think the only good use case I have for 50+ lines functions are finite state machines and renderers, whatever the form.

Do you have other examples of 50+ lines functions where you thought it was the best to not separate issues?



Specialized parsers. Encoding and decoding tasks. Complex computation is often isolated to help with peer review. Pattern matching routines.

Also, constructors with many validation steps that are compiler constrained to their local scope. That seems common.


Aren't specialized lexer/parsers finite state machines? As are encoder/decoders?

OK fir complex computation, I left the world of mathematics 7 years ago, and I wasn't at the edge on that, I trust you, but to be clear, all your examples scream 'FSM' to me. If you have a pattern matching routine of 50+ lines that isn't a finite state machine, you're doing something wrong imho, and should consider changing abstraction (I'm not a big OO guy, but maybe use dynamic dispatch?)


Yeah any routine that is not Turing complete is a FSM. Most things are FSM, so it’s not a useful distinction


Anything consisting primarily of a switch statement with a great many cases.


Finite state machines then. I never used more than 3 cases unless I had to write one.


Also event dispatchers. I've written switch statements for various event systems that need to handle 60-100 events. You can easily get to hundreds of lines without things getting unreadable.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: