Skip to main content
Filter by
Sorted by
Tagged with
1 vote
0 answers
114 views

Please excuse me for how long this question is. I tried to shorten it as much as possible while still listing all of the various things I've tried and the problems I've run into. I have a state ...
DavidTriphon's user avatar
0 votes
0 answers
44 views

I am trying to implement an HR management module wherein I have three 3 types of employees namely RegularEmployee, ReengagedEmployee, OutsourcedEmployee. All of them have some common properties like ...
genuinebookworm's user avatar
0 votes
1 answer
69 views

I am looking for a more idiomatic or concise OOP pattern to implement the equivalent of the following. Interface and implementations from abc import ABC, abstractmethod from typing import override ...
bmitc's user avatar
  • 908
1 vote
1 answer
1k views

I'm working on a quite significantly sized web application that heavily interacts with Google Maps using Vue3 with composition API, typescript, and Pinia store. The application is not complicated in ...
borndeprecated's user avatar
-1 votes
2 answers
275 views

I am having this issue: System.InvalidOperationException: 'A circular dependency was detected for the service of type 'LibraryExamples.Water.States.IGasState'. LibraryExamples.Water.IWater(...
S. LaBani's user avatar
1 vote
1 answer
149 views

I am implementing the State design pattern in TypeScript and have run into circular dependency issues between Context, State, and state classes (StateA and StateB). // context.ts import { State } from ...
borndeprecated's user avatar
0 votes
1 answer
571 views

I am implementing a noise gate in Python, using the state design pattern. My implementation takes an array of audio samples and, using the parameters of the noise gate, the audio sample magnitude ...
dg0802's user avatar
  • 3
0 votes
2 answers
83 views

I have a a class course which uses the state pattern to model the state of a course. A course starts as a draft, can then be handed in to be approved by an admin. If the course was approved it can be ...
ThiloOS's user avatar
  • 92
0 votes
1 answer
186 views

When using state pattern, one is delegating behaviour of the Entity to the current State. I have prepared SSCCE that I pasted below. We have an Entity which can transition between states : StartState, ...
Yoda's user avatar
  • 18.2k
1 vote
3 answers
1k views

I have a struct with several states: struct Select; struct Insert; struct Delete; // ...more states struct Query<T> { // ... some non-generic fields marker: PhantomData<T> } I ...
hjpev's user avatar
  • 771
3 votes
0 answers
78 views

In a previous question on StackOverflow, I asked about preventing the Context class within a State design pattern from having too many responsibilities, and I received an answer on that (moving it all ...
Angel Hadzhiev's user avatar
2 votes
1 answer
523 views

I am making use of the state design pattern for a project of mine where I have a Car class which is the context class and it can have 3 states - neutral, drive and park. In each of those states, the ...
Angel Hadzhiev's user avatar
0 votes
2 answers
660 views

I am building an Enemy AI State Machine, Where I have these scripts. Setup Enemy EnemyStateManager EnemyStateBase States InitialState RoamingState PursuingState AttackingState RetreatingState When ...
Katerlad's user avatar
1 vote
0 answers
320 views

I'm working on a Flutter widget that uses the state pattern whereby the layout changes in reaction to the state of an underlying model, so effectively there is a portion of the widget tree being ...
Nerdy Bunz's user avatar
  • 7,743
3 votes
1 answer
689 views

So I have been reading some design patterns on refactoring.guru, and have especially had an interest in behavioral design patterns. However, there is one design pattern that made me question if it is ...
Himanshu Naidu's user avatar
0 votes
0 answers
230 views

I've been interested in working with Rust for a while and wanted to recreate one of my school projects in it. This project involves creating an Order which goes through multiple stages much like this ...
TheCodingDragon's user avatar
3 votes
1 answer
1k views

I'm studying design patterns in .NET and currently i'm trying to implement the State Pattern. But today i got to a problem and i can't figure out how to fix this situation. I have some state classes, ...
VieiraHeloisa's user avatar
1 vote
2 answers
974 views

Main question What are some good ways to manage state machine versions (including states themselves, state transition methods, etc) in object-oriented design, particularly during deployments when ...
frankp124's user avatar
0 votes
2 answers
249 views

I´m trying to implement the State-Pattern using C# following this page. Here the UML of a State-Pattern. The State it self sets the new sate in the context class. But here is my problem: I want to ...
Felix Arnold's user avatar
3 votes
1 answer
676 views

Dart 2.17 now has enhanced enums. Matt Carroll mentioned in his review that you could use the new enums to implement the State Pattern. I'm having trouble with this because I'm weak on both the State ...
Suragch's user avatar
  • 516k
0 votes
0 answers
357 views

I need to implement a state pattern in JPA. I'm working with a delivery System for products. I can create orders, each order contains an order status (for example: Sent, Delivered, Cancelled, etc), so ...
Mauro Alvarez's user avatar
0 votes
0 answers
190 views

I really know that when we have a state-dependent behaviour, we automatically think of state design pattern, especially when it comes to a behaviour that changes according to the state and at the same ...
Abdelkrim ZAHMOUNI's user avatar
2 votes
1 answer
330 views

I am using the state pattern and I need to know in which state a given object is to print it. I thought about using an abstract method returning a string that each state would override with its own ...
Pooyanoss's user avatar
1 vote
1 answer
190 views

I have problems finding the right place for an actor and a timer used in a state machine. I found some inspiration from this site about the state pattern: State Design Pattern in Modern C++ and ...
Celeano's user avatar
  • 11
1 vote
0 answers
776 views

I have a scenario, where I am using the State pattern. Every Start has an Action defined. We start with an initial state and an initial Action and then keep going until the Action becomes null. If the ...
Gurucharan Sharma's user avatar
0 votes
1 answer
517 views

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
0 votes
1 answer
164 views

class Tool { public: virtual void mouseUp(); virtual void mouseDown(); virtual ~Tool(); }; class SelectionTool : public Tool { void mouseDown() override { std::cout << &...
stiwenparker's user avatar
0 votes
1 answer
138 views

I'm trying to implement State pattern in C++. Here an example code: #include <cstdio> class Context; class State { public: virtual ~State() = default; explicit State(Context *context) ...
zenno2's user avatar
  • 453
3 votes
1 answer
101 views

I have implemented state pattern for my socket library in Java. I simplified code to reduce size and increase readability just to demonstrate the problem. I don't know how to encapsulate using of ...
zenno2's user avatar
  • 453
1 vote
1 answer
2k views

In embedded programming memory allocations are things that we want to avoid. So using design patterns like state design pattern is cumbersome. If we know how many states we will have then we can use ...
pallasz88's user avatar
0 votes
1 answer
1k views

I have a menu that can be in different states so I decided to use the state pattern. Reading online about the pattern seems like the usual way is to construct states from another state but this will ...
Argus Kos's user avatar
  • 185
0 votes
0 answers
64 views

I was trying to implement the state pattern in C#, and I did something like this: class Context { private State state = null; private State concreteState1 = null; private State ...
Ignacio's user avatar
  • 437
0 votes
1 answer
78 views

I need help with another solution in this Object-oriented design challenge! The technical leader asked me to give another solution. This is the challenge: An Army is made up of units. A unit could be ...
Max Stephen's user avatar
1 vote
4 answers
712 views

I am confused about state pattern implementation. Under this pattern, we should extract state management into separate classes. At first glance it allows us to avoid big if ... else ... constructions ...
Al Ryz's user avatar
  • 65
5 votes
2 answers
3k views

Recently, I've tried to create Snake game in SFML. However, I also wanted to use some design pattern to make some good habits for future programming - it was The State Pattern. But - there is some ...
Thorvas's user avatar
  • 93
2 votes
1 answer
764 views

Situation: My States have an entry() and exit() method that needs to be called every time when a State transitions. To ensure that, I used a changeState() method in State that contains the necessary ...
Horyzon's user avatar
  • 33
0 votes
1 answer
1k views

I got into this book called "game programming patterns" and I started implementing some of its patterns in C#. Right now, I'm implementing the State Pattern which is described by the UML Class Diagram ...
essrifi ayoub's user avatar
5 votes
1 answer
133 views

class HeavyweightObjcet { public void operate() { System.out.println("Operating..."); } } class LazyInitializer { HeavyweightObjcet objcet; public void operate() { ...
Osama Ahmad's user avatar
  • 2,368
0 votes
0 answers
57 views

In state design pattern ,In the worst case when a new state is added to parent State, it causes all other states to change as well.  What changes need to be made to the design to prevent successive ...
mrbelane's user avatar
  • 185
1 vote
1 answer
866 views

I'm new to design patterns, when I looked at the state class diagram, I found it's just a polymorphism applied. Nothing is special about it. Am I wrong?
Youssef13's user avatar
  • 5,397
0 votes
0 answers
286 views

First of all I would like you to know that I read different topics about: cyclic import, cycling type hints and so on. According to this answer we can notice that: States store a reference to the ...
Benek's user avatar
  • 91
2 votes
1 answer
307 views

I'm experimenting with using discriminated unions in C# (specifically, using the excellent OneOf library) as means of representing and performing state transitions, taking advantage of compiler-...
Dai's user avatar
  • 158k
2 votes
4 answers
6k views

I am looking into creating a very simple state machine. My state machine will contain the following 3 states: public enum States { PENDING, ACTIVE, DONE } There are multiple transitions + ...
thebighoncho's user avatar
0 votes
1 answer
1k views

In my application a user would enter a link for an image or a video. According to the type of media (image, video or Pin from Pinterest) the app will determine how to display a thumbnail of the ...
Tlink's user avatar
  • 913
2 votes
1 answer
874 views

I've been working for 2 months with different Camera2 API projects. As you may know, Camera2 API is little difficult to understand and maintain, it requires some knowledge of multiprocessing, states ...
404pio's user avatar
  • 1,024
0 votes
1 answer
574 views

I have to implement a state machine with very basic requirement that every state pattern should have: The state machine can be in any ONE state at a time. The transition from X state to Y state will ...
shabby's user avatar
  • 3,282
3 votes
0 answers
304 views

I've been looking for a natural way to implement state-dependent behaviour (state machines) in Python objects. The goal was for objects to have a small number of states, or "mutually orthogonal" ...
Alexey's user avatar
  • 4,111
3 votes
4 answers
5k views

Everywhere I find people saying it is better to use state design pattern over if else. I want to know why: It is an improvement to if-else in real world use case? Does it make code more testable? can ...
Nikhil Kamani's user avatar
0 votes
1 answer
146 views

I read about state and strategy design patterns in refactoring.guru web site in pages State and Strategy. The author says This structure may look similar to the Strategy pattern, but there’s one key ...
M a m a D's user avatar
  • 2,189
4 votes
2 answers
5k views

I am having some issues wrapping my head around on implementing the state design pattern in Python. I am new to Python and wrote some code to try and answer this question that was presented to me: ...
Paresa's user avatar
  • 41

1
2 3 4 5