State
State is a behavioral design pattern that lets an object alter its behavior when its internal state changes. It appears as if the object changed its class. The State pattern is closely related to the concept of a Finite-State Machine . Finite-State Machine. The main idea is that, at any given moment, there’s a finite number of states which a program can be in. Within any unique state, the program behaves differently, and the program can be switched from one state to another instantaneously. However, depending on a current state, the program may or may not switch to certain other states. These switching rules, called transitions, are also finite and predetermined. You can also apply this approach to objects. Imagine that we have a Document class. A document can be in one of three states: Draft, Moderation and Published. The publish method of the document works a little bit differently in each state: Possible states and transitions of a document object. State machines are usually impleme
/ Design Patterns / Behavioral Patterns State Intent State is a behavioral design pattern that lets an object alter its behavior when its internal state changes. It appears as if the object changed its class. Problem The State pattern is closely related to the concept of a Finite-State Machine Finite-State Machine: https://refactoring.guru/fsm . Finite-State Machine. The main idea is that, at any given moment, there’s a finite number of states which a program can be in. Within any unique state, the program behaves differently, and the program can be switched from one state to another instantan
Explore this link on the map →related reading
- A Complete Introduction to State Machines in JavaScriptjonbellah.com
- Design Patternsgrantslatton.com
- Design Patternsrefactoring.guru
- Mementorefactoring.guru
- Redux Essentials, Part 1: Redux Overview and Concepts | Reduxredux.js.org
- State as a Snapshot – Reactreact.dev
- Tutorial: Tic-Tac-Toe – Reactreactjs.org
- Strategy in Rust / Design Patternsrefactoring.guru
- Updating Objects in State – Reactreact.dev
- @StateObject 和 @ObservedObject 的区别和使用 | OneV's Denonevcat.com
- Reading 19: Little Languagesweb.mit.edu
- Abstract Factoryrefactoring.guru