4 ms·
I’ve become a big fan of using finite state machines (more specifically xstate [1]) to encapsulate all the logic and states of a particular UI. You can essentia
by adamkl 8y ago
I’ve become a big fan of using finite state machines (more specifically xstate [1]) to encapsulate all the logic and states of a particular UI. You can essentially create all the behaviour of your application without writing a single line of UI code. At that point, you can use React exactly as you described, as pure functions of data.
[1] https://github.com/davidkpiano/xstate https://github.com/davidkpiano/xstate
- matb33 8y agoAs a company we’ve been experimenting with xstate for about a year. Generally speaking, bug counts go down as a direct result. We’re at a point now that it’s part of our process — a key deliverable as part of our first phase of development is what we call a “navigational statechart” which informs the development of the wireframes. The beauty of this process is that we can take that same statechart directly into the later development stages.
- adamkl 8y agoWe recently did a proof-of-concept at my company and came to some similar conclusions. We can see state charts driving our development process exactly as you described, so it’s good hear that others are finding success with this approach! We are going to be incorporating xstate at a basic level in one of our next projects, but I’d eventually like to see it become entrenched in how we do all UI development.
- drbojingle 8y agoI've been experimenting with this lately for chatbots and I feel like it could be a good approach.
- adamfeldman 8y agoI've been doing this using Fulcro [1], a ClojureScript web framework built around React. Among other wonderful features, Fulcro has built-in support for state machines [2]. [1]: https://github.com/fulcrologic/fulcro https://github.com/fulcrologic/fulcro [2]: https://github.com/fulcrologic/fulcro-incubator/blob/develop/state-machine-docs.adoc https://github.com/fulcrologic/fulcro-incubator/blob/develop...
- davidkpiano 8y agoReally awesome to hear! I strongly agree with the notion that all popular front-end frameworks have an API that encourages tying business logic with UIs, and this is has been a known anti-pattern for decades now.