Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more

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
2 votes
7 answers
411 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://...
wcminipgasker2023's user avatar
0 votes
1 answer
93 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 ...
afrish's user avatar
  • 103
0 votes
1 answer
89 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 ...
Solruhama's user avatar
12 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 ...
Mehdi Charife's user avatar
1 vote
5 answers
330 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 ...
sharbel okzan's user avatar
1 vote
3 answers
361 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 ...
wcminipgasker2023's user avatar
0 votes
1 answer
152 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 ...
TomR's user avatar
  • 1,003
0 votes
1 answer
64 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 ...
aterbo's user avatar
  • 111
-1 votes
1 answer
220 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 ...
yokus's user avatar
  • 7
0 votes
1 answer
196 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 (...
kaan_a's user avatar
  • 155
3 votes
2 answers
346 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 ...
PieterV's user avatar
  • 215
0 votes
3 answers
523 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 ...
EspressoCoder's user avatar
10 votes
7 answers
1k 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 ...
Angelica's user avatar
  • 109
0 votes
1 answer
848 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 ...
carlo_barth's user avatar
0 votes
0 answers
58 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 ...
Patrick Wright's user avatar
0 votes
1 answer
124 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 ...
Tamlyn's user avatar
  • 167
-1 votes
1 answer
387 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 ...
Martin's user avatar
  • 1
0 votes
2 answers
133 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 ...
user2190492's user avatar
1 vote
1 answer
417 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 ...
Christopher Pisz's user avatar
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 ...
CoderDesu's user avatar
  • 1,015
1 vote
1 answer
244 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 ...
Khuram's user avatar
  • 137
-3 votes
1 answer
121 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 ...
J. Doe's user avatar
  • 103
4 votes
1 answer
536 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. ...
Karl 17302's user avatar
3 votes
3 answers
696 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 ...
Unknown Coder's user avatar
0 votes
0 answers
69 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'...
Mohammad Mehdi Sarfejoo's user avatar
2 votes
3 answers
365 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) ...
hasanghaforian's user avatar
3 votes
3 answers
762 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. ...
Michael Macha's user avatar
3 votes
2 answers
442 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 ...
Géry Ogam's user avatar
-2 votes
1 answer
200 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 ...
funct7's user avatar
  • 162
2 votes
2 answers
609 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 ...
Géry Ogam's user avatar
-2 votes
1 answer
374 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 ...
FedeC87p's user avatar
-1 votes
1 answer
112 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 ...
Krupip's user avatar
  • 1,300
1 vote
2 answers
485 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 ( ...
ama's user avatar
  • 21
0 votes
2 answers
992 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 ...
orb's user avatar
  • 9
1 vote
2 answers
180 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 ...
Magnus's user avatar
  • 415
-3 votes
1 answer
435 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'; ...
Paul Draper's user avatar
  • 6,022
-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 ...
pythonlearner's user avatar
2 votes
1 answer
562 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 } } ...
becomeocean's user avatar
0 votes
1 answer
358 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 ...
Bryn Davis's user avatar
2 votes
1 answer
154 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 ...
Maciej Pszczolinski's user avatar
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 ...
imperialgendarme's user avatar
0 votes
1 answer
48 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 ...
WHITECOLOR's user avatar
0 votes
2 answers
205 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 ...
boarnoah's user avatar
1 vote
1 answer
182 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 ...
d33tah's user avatar
  • 143
0 votes
1 answer
99 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 ...
Heinzi's user avatar
  • 9,768
2 votes
1 answer
158 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 ...
Anthony Kong's user avatar
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 ...
celsowm's user avatar
  • 253
0 votes
1 answer
476 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 ...
Sven's user avatar
  • 109
2 votes
1 answer
382 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 ...
Gulzar's user avatar
  • 1,240
1 vote
1 answer
4k 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 ...
apex39's user avatar
  • 121