Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [state]

The tag has no usage guidance.

1
vote
1answer
53 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 ...
0
votes
1answer
52 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 ...
1
vote
2answers
91 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 ...
0
votes
1answer
32 views

If I need connection to get data, then display the data at controller A, 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,...
3
votes
3answers
167 views

What to do when an aggregate is given a bad event?

What is usually done when an aggregate is asked to apply an "impossible" event to its state? For example, if a ShoppingCart aggregate has already applied a CustomerAckRec (The customer has ...
6
votes
1answer
226 views

Is private global mutable state ever appropriate, namely when used to prevent API misuse?

I am writing a type checker for an ML dialect that involves generating "fresh" (new and unique) "type variables" (values representing unknowns). My strategy, and the strategy that seems to be used in ...
0
votes
0answers
59 views

Hierarchical state machine. Is there a term for the deepest nested state in a state configuration?

A flat state machine has one active state. In a hierarchical state machine (HSM), if the HSM is in a child state, it's also in it's parent state. So, an active state configuration of an HSM consists ...
1
vote
1answer
54 views

What's a clean way to manage state in Angular and have components update?

I'm using a service to manage state in Angular: import { Injectable } from '@angular/core'; import { Subject } from 'rxjs'; @Injectable() export class DrawingAreaService { itemChange: Subject<...
1
vote
2answers
86 views

How to implement online/offline data synchronisation?

I want to create a desktop application. The application must be able to accept database transactions even if internet connection is lost, but as soon as internet connection is available the ...
1
vote
3answers
582 views

Better to use Global Variable or Coroutine in general?

Is it better to store state in a global variable or in a coroutine, specifically in python? I don't understand best practice here. As an example consider a simple flask script. from flask import ...
0
votes
1answer
117 views

How to avoid Global State with a world map?

This is a conceptual problem I'm having general difficulty with, and I'd like to look at an example that can hopefully help clarify this: using a map to represent an alterable game world. For ...
1
vote
0answers
24 views

React JS: Mixing data types for one state property

In the spirit of minimising state I always have a desire to mix data types for a given state property. For instance, if I were creating a React page that rendered a list of items that could either be ...
1
vote
1answer
191 views

Handling error in multiple state machines in embedded systems in C

I have few state machines which run "concurrently" in a super loop. do { state_one(); state_two(); state_three(); /* The point I want to deal with the error */ } while(1); Each of these ...
1
vote
1answer
101 views

What does it mean “state complects value and time”?

I'm rewatching Rich Hickey great talk "Simple Made Easy" And around min 35:40 when talking about state, mentions that State complects value and time, but I'm not sure I'm understanding this well. Is ...
1
vote
1answer
275 views

How should I structure React Redux components when requesting Data From an API?

I have a search box I'm going to use on different pages (I use the term 'page' loosely here). The search box puts its value (the search string) into the Redux state. The results are populated from an ...
2
votes
2answers
77 views

3 tier application state handling

The objective of my application is to control and monitor sensor based equipment (temperature, humidity etc). Data from the equipments is transmitted using GSM, Ethernet or Serial port channels. When ...
6
votes
1answer
2k views

React: Nested object as state vs individual properties

Are there any use-cases where a nested object as state is either more optimal/easier to work with than individual properties? For instance if I wanted to express some user controls for interacting ...
1
vote
2answers
380 views

What's the proper way to think about state monads?

I've been using a functional approach in my programming of late. I know that mutability and state changes are big no nos within the paradigm. I now find myself working with databases and other data ...
2
votes
2answers
198 views

Get value from UI element or from variable

I had a debate with a friend and I'm looking for a way to resolve it and decide which approach is better for maintenance and whether there's some consensus about a best practice regarding it: If an ...
-2
votes
1answer
55 views

Single Page Apps: handling state dependencies

If I have an React/Redux single page application that has - say - a customers page that lists businesses that are customers, and from there each customer can be accessed with a URL like this: /...
4
votes
3answers
161 views

Changing bot application state (Starting → Started → Stopping → Stopped)

I am developing a bot which I need to start and stop at will. I have 2 buttons in my form, StartButton and StopButton which change the state. The Bot has 4 possible states: starting, started, ...
0
votes
0answers
81 views

Can I avoid maintaining state across program invocations?

I'm working on writing a compiler pass in LLVM; as part of the pass, I need to create unique identifiers for certain instructions. I want this to be predictable and consistent, such that if I compile ...
0
votes
1answer
155 views

Using CSS classes to express state

Is it good practice to express the state of an HTML element--such as whether an input's value is valid--using a CSS class? Would it be better practice to use data attributes, the properties of a ...
0
votes
2answers
111 views

Techniques for observing runtime state in C

What are the techniques for C programs which allow easily inspecting the state of the embedded device, through a communication link? For example, for a microcontroller device which communicates with ...
3
votes
4answers
1k views

Does object-oriented programming allows side effects and state changes?

I know that obviously every language has its own characteristics and implementations, but from a theoretical standing point, viewing OOP as an abstract programming paradigm, does it allows side ...
0
votes
0answers
389 views

How should I code a multi-type observer pattern?

We have some states, depending on a window that is currently active: public enum LoginState{ NONE, LOGGIN_IN, LOGIN_SUCCESS, LOGIN_FAILED } public enum LobbyState{ NONE, ...
0
votes
1answer
145 views

Redux: When Should I Keep Track of State and When Should I Not?

NOTE: I am new with the whole concept of state management. I never got into the older languages that "explicitly used" states. I dived into React and Redux for the past week, and as I'm getting into ...
-2
votes
1answer
215 views

HTML5/Canvas Graphics editor and Immutable state (EaselJS and Redux, ngrx/store)

This question is about the architecture approach. How would someone go about creating the immutable state for a graphics editor that would eventually provide an "undo/redo" functionality, considering ...
12
votes
4answers
994 views

When programming in Functional style, do you have a single application state that you weave through the application logic?

How do I construct a system that has all of the following: Using pure functions with immutable objects. Only pass into a function data that the function it needs, no more (i.e. no big application ...
4
votes
2answers
103 views

How to to send a file and record that it has been sent in an atomic way?

I'm not sure how to best approach this problem. I've got an object in my local database, for example this one: { title: "my-object", uploaded: false } I convert this to a file, say my-object.txt and ...
81
votes
8answers
24k views

How to keep applications stateless

This may be a convoluted question, but I'm trying to get a better understanding of statelessness. Based on what I've read, web applications should be stateless, meaning each request is treated as an ...
4
votes
1answer
553 views

What is a (Redux) selector?

I am learning Redux (a JavaScript state container tool). I am finding numerous references to something called a "selector" (e.g. here, here, here, and here). However, I don't seem to be finding a ...
3
votes
1answer
301 views

Is global state evil if it doesn't change behavior?

I have a library in C where the API uses "objects" to interact with the application. These "objects" are opaque pointers that are created, destroyed, and modified via API calls. These "objects" do ...
1
vote
1answer
165 views

Can I, Should I, How do I refactor for vuex - redux?

We need to get more much more rigorous about managing state in our business application. The heart of our problem is an object, lets call it an "TaxRefundApplication", that has about 20 properties, ...
7
votes
2answers
601 views

How to store and validate data between state transitions?

I'm developing a largeish application that will have custom finite state machines. That is, the admin users of the application will be able to create their own state machines, limited by little pieces ...
3
votes
1answer
194 views

UML “direct substate” vs “transitively nested substate”

I am reading through Wikipedia's page on UML state machines. I don't understand where it says: A nested state is called a direct substate when it is not contained by any other state; otherwise, ...
3
votes
2answers
657 views

State handling in WPF-MVVM

I am looking for advice on handling states in a WPF MVVM environment. As an example, assume we have A TreeView (or some other ItemsControl) with some items and a button that is enabled when an item ...
0
votes
2answers
416 views

Using Static vs Passing Parameters

I'm implementing a state-pattern design in Java to calculate the current position of an object following a trapezoidal trajectory. The pattern consists of a Context, State and states classes. ...
5
votes
3answers
3k views

Stateful vs stateless (non web app) applications

I would like to understand the difference between stateful and stateless applications. What would be a non web app example of a python application which is stateless vs stateful? Would a script which ...
3
votes
1answer
168 views

Should a State Machine or Processing Engine be abstracted away from the UI?

I'm working on a suite of micro-services, with a web-based GUI. We are using a 3rd party state machine via REST calls. Sometimes we get/set state from one of our micro-services, while other times we ...
2
votes
2answers
295 views

Simulated functional programming in C — passing the entire program state as a function argument

I have a struct called State which holds all the variables for the program. Rather than being modified by functions directly, it is the value returned. Here is some code: #define USERNAME_LENGTH 20 #...
3
votes
2answers
212 views

GUI applicaton states and polymorphism

I have WinForms GUI application, which can work in two "states" with different functionality, but these states share GUI controls. I am dividing these states by using enum almost in every method, like:...
1
vote
1answer
114 views

Does passing this as argument potentially cause exposure of invalid object state?

This question is based on two premises: First: an object must always have valid state. It is discussed in various posts, too. https://stackoverflow.com/questions/22408804/should-a-c-object-always-be-...
1
vote
2answers
934 views

State Design Pattern

I've come across the following State Design Pattern which seems extremely logical and simple to implement: class CeilingFanPullChain { private State m_current_state; public ...
246
votes
22answers
14k views

How are globals any different from a database?

I just ran across this old question asking what's so evil about global state, and the top-voted, accepted answer asserts that you can't trust any code that works with global variables, because some ...
15
votes
11answers
4k views

What is better IllegalStateException or silent method execution? [closed]

Let's say I have a MediaPlayer class which has play() and stop() methods. What is the best strategy to use when implementing the stop method in case when the play method has not been called before. I ...
16
votes
1answer
3k views

Is there a good formal pattern to manage state in MVVM?

I have started learning about Redux and React in the web-world, and the more I learn about it the more I'm realizing how painful state management is in the desktop-world with WPF's MVVM-style ...
2
votes
1answer
97 views

Possible DRY with Pausing Mechanism

Background I am currently working on the architecture for a future software design. The design is one long running task (hours-long) with thousands of sequential calls to various libraries. I ...
0
votes
0answers
52 views

How to save the differences between objects which are the result of random changes?

I keep a state object of the following form: class State { int num1, num2; List<String> strings; MyObject myObject; // A class I wrote // etc. } The state changes many times ...
7
votes
1answer
239 views

Should I use a Status field or rely on calculations?

A bit long, but the overall the question is: Should I have a status field in the table, or should I calculate the status in-memory from other information in the record? What are the pro/cons of each? ...