Questions tagged [state]

Use the [state] tag for questions pertaining to retained information determining the behavior of a program.

Filter by
Sorted by
Tagged with
-1 votes
1 answer
73 views

State machine using SOLID principles. Connecting to real devices

I am trying to implement code for switching states of a couple laboratory devices. My considerations are: how should I link the state objects, state machine object and device manager object to follow ...
user avatar
  • 1
0 votes
2 answers
104 views

Make date range generator interface stateful or stateless?

An app has a feature that's much like any calendar application (like the Outlook calendar for example). Consequently, I need to do a lot of date logic. I wrote a class with date calculation methods ...
user avatar
0 votes
1 answer
71 views

Hierarchical State Machines - Ortho Regions

I am rather unclear about how an event gets processed when a state machine has orthogonal regions. I did read that With composite states, that an event should be sent to the innermost state, and if ...
user avatar
48 votes
3 answers
7k views

Are front-end state management tools an anti-pattern?

I'm currently reading "Code Complete" by Steve McConnell. In section 13.3 "Global data" in last paragraph "Don’t pretend you’re not using global data by putting all your data ...
user avatar
  • 965
1 vote
1 answer
101 views

State Pattern when the Behavior in Object of Type A is Dependent on the State of the Object of Type B

I have used the state pattern for my web application where a user can be in one of three states: activated, required_activation and suspended. I have created 3 states classes as given below (source is ...
user avatar
  • 137
-3 votes
1 answer
89 views

How would a stateless server handle events when the user disconnects?

I want to build a chat application with a stateless server as backend. Users have an online and offline status. When a user connects to the server, the server marks that user as online. Now imagine a ...
user avatar
  • 103
4 votes
1 answer
100 views

Using Choice Node in State Machine Diagrams

In State Machine diagrams, in some online resources, the condition is merely drawn on the arrow (the left figure below) and in others similar to right figure, where a choice node is specifically used. ...
user avatar
3 votes
3 answers
434 views

What algorithm should I use for this game problem?

I have a grid-based puzzle game, that is based on states. I need an algorithm that can find a solution for each game level. A game level starts in a specific state and ends in a unique, well-known ...
user avatar
0 votes
0 answers
29 views

How to deal with dirty state when view-model doesn't match backend model?

I have some code where the backend model has a nullable field. However, for the front-end forms that create the data for the model, a null value is not possible. So the front-end view-model has a non-...
user avatar
0 votes
0 answers
59 views

State Pattern: Changing object behavior based on more than one field and consistency between their values and state value

I'm Trying to learn about State Pattern. In most of State Pattern examples that I have seen, methods of class change their behavior based on just one field (I mean before applying State Pattern and I'...
user avatar
2 votes
3 answers
249 views

Definition of static property of object in OOP

Grady Booch in Object-Oriented Analysis and Design with Applications says: The state of an object encompasses all of the (usually static) properties of the object plus the current (usually dynamic) ...
user avatar
3 votes
3 answers
143 views

How does cuRAND use a GPU to accelerate random number generation? Don't those require a state?

My understanding is that every PRNG or QRNG requires a state to prevent the next item in its sequence from being too predictable; which is sensible, as they're all running on deterministic hardware. ...
user avatar
3 votes
2 answers
382 views

Is rebooting a server idempotent or not?

In his article RESTful Casuistry, Tim Bray claims that rebooting a server is not idempotent: But I don’t buy it, and here’s why. If I want to update some fields in an existing resource, I’m inclined ...
user avatar
  • 570
-2 votes
1 answer
72 views

Is there a name for this kind of state machine?

I'm thinking of a GUI architecture that works like a finite-state machine where there is a set of possible states and a set of possible inputs--or events. The thing is, some states transition to the ...
user avatar
  • 162
1 vote
2 answers
343 views

Roy Fielding’s REST alternative to HTTP cookies

I struggle to understand Roy Fielding’s REST alternative to HTTP cookies, § 6.3.4.2 ‘Cookies’ and § 6.5.4.1 ‘Application State in a Network-Based System’ of his doctoral dissertation Architectural ...
user avatar
  • 570
-2 votes
1 answer
190 views

DDD Best way to preserve integrity of entity

I have an entity that contain the status of data (WaitingForData, ReadyForData, DataUsed). class Batch { int Status { get; } DateTime StartTime { get; } string Code { get; } void ...
user avatar
-1 votes
1 answer
89 views

How to avoid context objects and designing "UI states"

Note: I'm using Dear IMGUI, OpenGL and C++. I have a UI, it has two "modes" one where it records and displays images and information about a recording device (IE camera) and another where it ...
user avatar
  • 948
1 vote
2 answers
147 views

Identifying states when using state machine to validate a form field

Scenario is simple, a password field with few validation rules. The states I came up with are default ( when the form loads or reset button is pressed) filled ( should this even be a state ?) valid ( ...
user avatar
  • 21
0 votes
2 answers
228 views

How do I delete items on the frontend that have been deleted on the backend?

I'm building a single page application with a timeline and loading those objects in from a paginated REST API. I'd like to delete objects that don't exist in the backend anymore or that have been ...
user avatar
  • 9
1 vote
2 answers
76 views

Best way to display errors from a model to the user?

I'm developing an app (using Flutter) that has a model that contains most of the business logic, and a view that displays the user interface. The model can call notifyListeners to inform the view that ...
user avatar
  • 405
-3 votes
1 answer
150 views

React one-way data binding vs Angular two-way data binding

After hours of reading blog posts, I understand that React has one-way data binding, and Angular has two-way. But I don't actually know what that means.... React import { useState } from 'react'; ...
user avatar
  • 5,872
-1 votes
1 answer
59 views

Storing failed states locally

I’m currently developing a web application and am struggling to think of a design for the front-end. In the front-end the user can input 1-n values and it will be split up into 1-n API calls. The api ...
user avatar
2 votes
1 answer
185 views

Is it an antipattern to pass an object that stores the application state from one function to another?

The program is written in JavaScript. To give you a rough idea what I am thinking of: function State() { return { color: 'green', size: 100, // ... there are other properties here } } ...
user avatar
0 votes
1 answer
79 views

HTTPSession for session state in web APIs?

We are building a set of web APIs. The web APIs are called by clients & can call each other. State is required by these APIs for the users session (e.g. shopping basket type stuff). The state ...
user avatar
2 votes
1 answer
84 views

Distributed cart state in microservices

We have legacy app which keeps state of a cart in local storage on a Frontend (this decision was made long time ago by other devs). The cart is cleared from local storage after 2 hours if it is not ...
user avatar
4 votes
4 answers
566 views

If a system talks to a database to get some previous information to serve a request, does that make the system **stateful** or **stateless**?

I've read this example which basically states that, since a method has to hold a single private field.. It is considered a stateful system. So basically ANYTHING system that calls upon some sort of ...
user avatar
0 votes
1 answer
35 views

How reducer without "change" argument should be called (referred)

Usually, when using "reducer pattern" we call reducer a function that takes previous value and change argument that should be applied. reducer: (state, event) => state In some cases, it ...
user avatar
0 votes
2 answers
135 views

Avoiding sequential coupling while maintaining separation of concerns

Got a desktop application that interacts with some stateful third party web APIs. Its an interactive application, at some stages it has to halt execution and prompt for user input based on responses ...
user avatar
1 vote
1 answer
91 views

When keeping all state in an SQL DB, how to handle one-off variables?

I noticed this pattern in my programs: I'm building a system, like the one I'm building for my local hackerspace right now. It's using database as its "brain" - a scraper as a separate ...
user avatar
  • 143
0 votes
1 answer
44 views

How should I represent a UI state change in the URL?

My web application has a UI. Some aspects of the UI can be changed (e.g. the language, the theme, the text size). As a concrete example, let's assume that I have a "theme" dropdown box available on ...
user avatar
  • 9,210
2 votes
1 answer
95 views

REST API: is it a violation of naming convention if a GET method changes the expiry of the a redis key?

I have proposed a REST API called 'getSessionState' which basically a backend API that retrieves some state info from a redis server and return to the clients. Because the state data is kept in a ...
user avatar
0 votes
1 answer
175 views

Could this be considered a valid State GoF Pattern implementation?

For teaching purpose, I would like to create a simple implementation of State Pattern using PHP 7.4. So, I've tried to create a simple "document state machine" starting with Draft, sending to review ...
user avatar
  • 243
0 votes
1 answer
196 views

What are differences in application architecture in frontend and backend applications?

I'm pretty experienced with developing both frontend as well as backend applications, with a variety of programming languages and frameworks. I know the problem space and concepts involved in both ...
user avatar
  • 9
2 votes
1 answer
221 views

State Machine: what object is responsible for state transfer?

I would like to create a state machine. Each State would have its run method, and, according to some logic would then set a next state. Option 1: If each state is responsible for determining a next ...
user avatar
  • 857
1 vote
1 answer
1k views

Calling a private method in a setter to update object at every change of the property

Code below shows setting a value of an object's property and calling a private method in a setter to update the status of the object. Is this call a good practice or setter at most should only ...
user avatar
  • 121
3 votes
2 answers
450 views

Syntactic characterisation of intrinsic and extrinsic states

Gang of Four’s Flyweight design pattern introduces the concept of intrinsic and extrinsic states: The key concept here is the distinction between intrinsic and extrinsic state. Intrinsic state is ...
user avatar
  • 570
2 votes
1 answer
104 views

What is a good API design for different available actions per mutually-exclusive states?

I am implementing a entity that has multiple mutually-exclusive states. In each state, there are different set of actions (let's say, transitions) that may take the entity to a different state. ...
user avatar
  • 2,688
0 votes
2 answers
266 views

Using UML State Machine for blockchain smart contract implementation

This is a conceptual question about applying UML State Machine model for smart contracts in blockchain. I want to develop a smart contract framework in a bitcoin-like blockchain which is based on the ...
user avatar
  • 3
1 vote
0 answers
186 views

How to avoid coupling of domain objects with UI data in a store-based Angular app?

The state of my TypeScript/Angular app contains objects from the UI layer and from the business domain layer. I'm exploring store-based solutions (eg ngrx, ngxs) to keep this state in memory. As ...
user avatar
0 votes
1 answer
122 views

How to keep state alive between deployments

In our history, when we did a new release (deployment) any user who was "logged in" was logged out and that was obviously not ideal. Then I switched platform from a custom stack to a cloud provider ...
user avatar
0 votes
0 answers
45 views

State Management design

I am working a product which have WebApi Android/ios app Web app WebApi is hosted in AWS EC2 . Currently we have requirement like we need to mantain state. Take one scenario. App have 4 pages. ...
user avatar
  • 99
10 votes
2 answers
3k views

Stateful vs non-stateful app [closed]

I have been learning about stateful apps vs non-stateful, but I am still a bit confused on this topic. For example, let's say I have an app running on Node where users are assigned to random rooms as ...
user avatar
  • 119
0 votes
2 answers
359 views

Is the global state believed to be evil because of its nature or mostly due to its usual, no-rules usage?

I don't dislike global state, but that could be due to the lack of experience. I was thinking about what the usual implementation of global state is: A big variable where data flows in a non-...
user avatar
  • 641
6 votes
1 answer
530 views

Is it better to use lambda functions or boolean variables to record state

I have heard some people claiming that boolean state variables are generally bad and should be avoided when possible. Apparently in many cases it is possible to put state into lambda functions, ...
user avatar
1 vote
1 answer
133 views

Are "I'm writing android applications" and "follow open-closed principles" reasons to allow global state?

For example, suppose I have an android application, in simple, there are 3 activities : MainActivity -> Main2Activity -> Main3Activity ,which user can visit them in sequence (eg: by button ...
user avatar
  • 5,572
1 vote
3 answers
146 views

Is it ok to duplicate a program memory to avoid inline reset?

I have a time-critical function that needs to be executed multiple times sequentially. void task(state_t *state); It uses a relatively large amount of memory, so I figured that allocating it once ...
user avatar
  • 119
2 votes
1 answer
68 views

How to restore to the correct state when the running process may get shut down thus missing some events?

Here are the requirements: (not the real case, just very simplied version) There is some sort of promotion which lasts for a week. The selected users who may benefit from the promotion is fixed at ...
user avatar
  • 151
0 votes
2 answers
451 views

Angular 7 - Injecting a State/Context Snapshot

Requirement There is some (for arguments sake) “global” application state that I am interested in injecting into components. Each candidate component should receive an immutable snapshot of the ...
user avatar
2 votes
3 answers
287 views

Are cascading drop down lists an example of a need to keep application state?

If I have a page with three cascading dropdownlists, is that an example of controlling the state of a web application (assume it is part of a larger application)? I want to make sure I understand ...
user avatar
  • 3,629
0 votes
1 answer
97 views

Should I "Connect->To controller A", or "To controller A->Connect"?

For example, suppose I have a shopping app, which has a user info page to show user info: class UserInfoController{ toPurchaseRecord(){ } } and a purchase record page to show purchase record,...
user avatar
  • 5,572