Questions tagged [state]
Use the [state] tag for questions pertaining to retained information determining the behavior of a program.
166
questions
0
votes
1
answer
245
views
Global Variables State Management
Background:
I am working in a Java environment using Spring Boot, where I often encounter scenarios where global variable state management is critical, especially within singleton services. I have ...
0
votes
0
answers
61
views
Best Practices for Managing State in React Applications
I'm currently developing a web application using React and I'm looking for the best practices for managing state effectively. I've come across several methods such as using the Context API, Redux, and ...
2
votes
7
answers
429
views
Why does "a consistent, understandable interface" differentiates database from global states?
According to some answers of How are globals any different from a database? that explains how database is different from global state:
https://softwareengineering.stackexchange.com/a/319389
https://...
0
votes
1
answer
133
views
Complex stateful logic in MVVM architecture
I'm building a mobile app in Flutter, and the project has several distinct layers. The top part is something better described as MVVM: dumb View layer that performs rendering and delegates actions to ...
0
votes
1
answer
130
views
when would I need state management like redux in my e commerce app?
I am new to React and web development generally so please try to understand if the question seems dumb.
So, I am currently making a simple e-commerce app and I was thinking of using state management ...
13
votes
4
answers
5k
views
Is there a clean way to model methods that only make sense depending on the current state of the object?
Let's say that I have a class called Mission. This class is intended to represent a mission requested by a professor working in a faculty. Mission has a private enum field representing whether the ...
1
vote
5
answers
351
views
Is storing computed values always bad?
Edit: I'm copying the question but changing the example code. Apparently, I used a bad example earlier that contained an imprue getter. I'm keeping the old example code at the bottom so the first ...
1
vote
3
answers
398
views
Why is Dependency Injection called "alternative of global state"?I think global state still exists
According to Why is Global State so Evil?, I believe we should avoid global state, so suppose I have an App that count user clicks in all pages like it:
public class GlobalState{
public int ...
0
votes
1
answer
198
views
Is it OK to stick with object graph in React State and should I make helpers for handling it?
I am trying to build ERP application using React frontend and I have not found decisive answer whether to use object graphs in React state?
E.g. I would like to build Invoice view and I have the ...
0
votes
1
answer
66
views
Including currect user/roles data within object state in .Net applications to control object behavior
I am building a .Net Core Blazor Server application. The application creates records of a Project class which move through a workflow with various phases of review and acceptance/rejection before ...
-1
votes
1
answer
275
views
When does a REST API stops being one in terms of state management?
As far as I understand, there is no certain boundaries for the RESTness of an API. However, I would like your help to understand how large and long (in terms of running time) a caching or state ...
1
vote
1
answer
213
views
Are there any drawbacks to partial application?
Consider the following Typescript code:
function exampleAction(target: Target, options: ExampleActionOptions) {
// ...
}
export function getExampleAction(options: ExampleActionOptions) {
return (...
3
votes
2
answers
382
views
How to implement a counter without global state?
I have read many blogs and stack exchange posts about global state (usually) being bad practice. I'm now trying to avoid this where possible in my code, but I'm running into a case where I don't know ...
0
votes
3
answers
567
views
Java Library - How to do Pure Dependency Injection When State is a Factor?
To set the stage, I am trying to do pure dependency injection for a Java Library I am creating to make it more testable. As it is a library, I want to do pure dependency injection without creating a ...
10
votes
7
answers
2k
views
Is global state really always bad?
I have a question regarding my general understanding of global state in software engineering.
When I write an app I like to decompose it into little, manageable components and functions, that are ...
0
votes
1
answer
941
views
How to share state between microservices
Consider a microservice architecture composed of a number of asynchronously communicating workers. Each worker deals with an isolated task and may have its own specialized database. Now consider that ...
0
votes
0
answers
59
views
UML Statecharts
I have been using an implementation of UML statecharts in C++ similar to that defined in the book "Practical Statecharts in C/C++" by Miro Samek (https://www.state-machine.com/psicc).
One of ...
0
votes
1
answer
127
views
Design for hardware UIs
What is a suitable software design approach for handling user input from hardware buttons, where the function of each button depends on state?
I'm designing a musical instrument which has a lot of ...
-1
votes
1
answer
398
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 ...
0
votes
2
answers
136
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 ...
1
vote
1
answer
489
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 ...
51
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 ...
1
vote
1
answer
262
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 ...
-3
votes
1
answer
123
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 ...
5
votes
1
answer
640
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.
...
3
votes
3
answers
718
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 ...
0
votes
0
answers
70
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'...
2
votes
3
answers
367
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) ...
3
votes
3
answers
898
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.
...
3
votes
2
answers
464
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 ...
-2
votes
1
answer
213
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 ...
2
votes
2
answers
625
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 ...
-2
votes
1
answer
383
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 ...
-1
votes
1
answer
113
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 ...
1
vote
2
answers
550
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 ( ...
0
votes
2
answers
1k
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 ...
1
vote
2
answers
233
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 ...
-3
votes
1
answer
461
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';
...
-1
votes
1
answer
61
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 ...
2
votes
1
answer
616
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
}
}
...
0
votes
1
answer
410
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 ...
2
votes
1
answer
166
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 ...
8
votes
4
answers
1k
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 ...
0
votes
1
answer
50
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 ...
0
votes
2
answers
228
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 ...
1
vote
1
answer
228
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 ...
0
votes
1
answer
108
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 ...
2
votes
1
answer
162
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 ...
1
vote
1
answer
258
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 ...
0
votes
1
answer
505
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 ...