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

State machine is useful when it is useful. I can see for certain string matching problem, internal management of certain data structure, it is going to be a handy improvement.

However, specifically in web development, it is discouraged because the nature of the application itself. Think hard how states are managed in a typical service, the real states live in a DB. Which makes state machine less useful because the ground truth is stored elsewhere, and should be updated by DB's own primitives. And in a distributed settings, failure is something you have to put into consideration. Making your service stateful is a red herring that brings all kinds of operational troubles. That is why the dominant approach people seems to agree upon is to keep application stateless while delegate all dirty work to DB.

So realistically I think state machine is useful to write certain helper routines in a non-persistent, single-thread scenario, for the ease of reasoning, but really should be limited within the lifecycle of a single API call.



Would like to read more on this subject if anyone knows any resources.




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

Search: