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

State makes things hard to manage. The more state there is in a program, the more things there are that can go wrong. If you can minimize state and express as much as possible in pure functions, then it's also much easier to write tests with well define inputs and outputs, and if anything causes problems it's easy to see which section caused it because all state originated from a single source.

Thus, stateless design style is easier to test, and even high level tests are more useful because of their high specificity when analysing test failures.



100% pure functions are the way to go where possible, writing simple code on state is already hard, asking the developer to invent their own abstractions to tie methods / state together is often asking for disaster when the specification changes and the abstraction no longer holds.


^ This.

Even when I didn't know what functional programming was, or even there was a thing called "programming paradigm", writing programs with a lot of functions made intuitive sense to me.

This approach was much simpler.




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

Search: