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 time this behaviour will change the state.
A VideoPlayer object - for instance - can move from ReadyState to PlayState to PausedState and again to PlayState and finally to TerminatedState at runtime and based on its state behaves differently regarding the UI and the source of stream.
This is a clear and not ambiguis example.
And for Strategy design pattern we have the search example, where we have to decide about the search startegy (The algorithm) based on system material (Memory concerns for example)
Yet this is a clear and not ambiguis example.
What if we have for example:
Sample 1:
A Request object that can be sent (The behaviour) to different systems according to its status (The Request class has status property) and can be not sent at all for some statuses, knowing that once sent or not it will not be resent (No change in its status after the sending is done - maybe later for other user interactions but not immediately). So in this case, do we consider it a State Design pattern (just because it depends on the Request status) or Startegy design pattern (Because the state of a particular object is evaluated once at the beginning and will not change) ?
Sample 2:
Searching (the behaviour) for certain objects is done differently based on the connected User Profile (A profile is sharable accross different users of course) The same question in this case. Do we consider it a Strategy, that we need to determine each time we execute the search user interaction or it is a state-dependent behaviour and thus should belong to the connected User object?
State VS Strategy design pattern
125 views Asked by Abdelkrim ZAHMOUNI At
0
There are 0 answers
Related Questions in DESIGN-PATTERNS
- Will it slow down the performance when Unit of work pattern is used with EF Core
- Design patterns - How Design patterns work with bulk data
- Using Repository pattern to fetch data from different places and build list of objects
- Suggest best design patterns to update or insert bulk data
- Mapping one collection of objects into another collection of objects
- How can I break down a large presenter in the Viper design pattern into smaller pieces?
- How to create under the label in Textformfield, not a border, in Flutter
- Own Pattern / framework for interfacing with components in C
- Common Method Implementation for Elasticsearch and OpenSearch Java SDK
- How can I decouple them?
- Understanding Potential Deadlock in Resource Pool Implementation Described in "Go in Action"
- Dependency Injection Patterns stand alone implementaion
- How to use GoF design pattern for software robustness?
- Pipeline data processing and code architecture
- Mocking inherited class where new object is created or how to unsmell my class
Related Questions in STRATEGY-PATTERN
- Code Snippet : Bridge Pattern or Strategy Pattern?
- esp32 rssi based tracking - Consultation
- Design approach for safely picking between multiple payment methods
- Type mismatch in Kotlin when using strategy pattern with generics
- How can I implement an object of strategies with same API but that only the provided argument options differ for each strategy?
- Pine script version change and stop reprint and repaint issue
- How to use mutable references as arguments for generic functions in rust
- Why my strategy doss not execute in tradingview? it creates no trade? caution! this strategy did not generate any orders throughout the testing range
- How do you implement the strategy pattern using Flutter and Riverpod?
- Is this Command Pattern or Strategy Pattern?
- How to conditionally select concrete implementation for strategy pattern using Dependency Injection C#
- The issue is that it should show the price values (coordinates) from which the line comes on a price scale, not on a graph! How to fix it?
- Implement Strategy pattern with Guice DI
- How to run different logic from Master page for different tab in TabContainer
- Java i can not initalize reference varibale in subclass because "VariableDeclaratorId expected after this token"
Related Questions in COMMAND-PATTERN
- Combining Command and Visitor design patterns
- Should you use the Command Pattern for requests involving very little logic?
- Is this Command Pattern or Strategy Pattern?
- Command pattern, EF Core, type casting and MS DI
- Why can't std::visit disambiguate templated overloads
- Am I applying command pattern correctly?
- mypy does not recognize a method of a class
- What are the differences between the Mediator and Command Design pattern?
- How to proper implement Undo Redo system in React using context and command pattern?
- Command pattern implementation
- How to apply command pattern in js
- Command design pattern with friend class in C++
- command pattern vs strategy pattern in Javascript
- State VS Strategy design pattern
- Undo-Redo functionality using Command-Pattern in Qt for FitInView feature
Related Questions in STATE-PATTERN
- Is it a feature envy code smell if a state class within the state design pattern uses a field object of the context class to call a method?
- Managing Reactivity for Complex Nested Objects in Vue3
- Circular dependency was detected when I tried to implement state pattern
- Circular Dependencies in TypeScript with State Pattern
- State pattern - determining the next state from multiple options
- Role dependent behaviour in state pattern
- How to elegantly define shortest happy path between start and end state in a State Pattern design implementation?
- Rust typestate pattern: implement for multiple states?
- How to keep the interface segregation principle while using the state design pattern?
- How to prevent a context class using the state design pattern from having too many responsibilities?
- For Enemy AI State Machine In Game Design, Should the State Itself Evaluate Logic to Transition to Next State?
- How to use Shared Element Transition and State Pattern Together in Flutter?
- Alternatives to State Design Pattern
- Combining the state and observable patterns in Rust
- .NET - It is possible to use DI with the State Pattern?
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)