Questions tagged [strategy]

A strategy is a general approach used to achieve goals, to address similar needs, or to solve a family of issues.

Filter by
Sorted by
Tagged with
0 votes
0 answers
63 views

Prevent users from creating "global" database connections for a forking general purpose server?

I've created a general purpose scalable server in PHP. It's scalable in that the main process merely listens for incoming connections and immediately distributes them to forked child processes which ...
user avatar
-3 votes
1 answer
72 views

Combining Strategies (Design Patterns) [closed]

If I have two boolean variables B1 and B2 whose value combinations cover four independent behavior functions (MFF, MFT, MTF, MTT), then how many concrete strategy (design pattern) classes should I ...
user avatar
2 votes
1 answer
102 views

How to implement Gang of Four's Lexi's Compositor-Composition?

I'm studying Design Patterns book and I was trying to understand the Composition principle in Lexi's Compositor-Composition as explained in figure 2.5, as well as how to implement it. Where the ...
user avatar
0 votes
3 answers
105 views

Strategy & Architectural Decision: Customer data migration between two companies

Asked this originally here, and didn't receive any answer so far, hence posting here too. Let's say company A acquired company B in a certain region. This means, A and B were competitors in that ...
user avatar
  • 109
-4 votes
4 answers
853 views

Disadvantage of the strategy pattern and how to overcome it

An often quoted disadvantage of the strategy pattern is: The application must be aware of all the strategies to select the right one for the right situation Why is this a disadvantage and what can ...
user avatar
  • 139
7 votes
2 answers
358 views

The "real and effective" GIT CI/CD strategy

I've started in this new company a few weeks ago, this is the CTO CI strategy: Current: Developer team has the repo prod/master and they merge everything into master (no branching strategy). Once the ...
user avatar
0 votes
1 answer
682 views

Discount calculation pattern

I am implementing a discount calculation model. One item PER order. I do have a Product class: public class Product { public string Name { get; set; } public Size Size { get; set; } public ...
user avatar
  • 117
2 votes
3 answers
836 views

Reconciling MVC with a strategy pattern

I am working on a Rails application which employs a classic MVC as its fundamental structure. In that structure the controller is supposed to be responsible for "which view to render when". Now after ...
user avatar
  • 143
17 votes
5 answers
2k views

How to comprehend abstraction in code?

When looking at a new codebase I like to start from a bottom-up approach. Where I comprehend one file and then move up to the next abstraction. But often times I find myself forgetting what the ...
user avatar
1 vote
1 answer
102 views

(Fuzzy) Data duplication detection - scoring systems strategy

Many systems that store data in a structured manner (although this is marked language agnostic, the origin of this question is an MS SQL database) struggle with duplicates. Taking a physical person/...
user avatar
0 votes
2 answers
149 views

Strategy to review all occurrences of specific field in large project

The project I am working on has a status field which currently only allows YES or NO, and I am about to refactor it to allow the value MAYBE. Unfortunately, it is used over 1,000 times in 200+ files. ...
user avatar
  • 109
9 votes
4 answers
3k views

Rich domain model vs strategy pattern in DDD

I've recently watched a few Pluralshigh courses on DDD by Vladimir Khorikov. He was encouraging to create a rich instead of anemic domain models. It all looked very nice in a small test-project, ...
user avatar
2 votes
2 answers
578 views

Algorithm for splitting players into unique group every round

For a match I have certain number of players, certain number of groups (players and groups are aliquot) and certain number of rounds to be played (players are reshuffled every round). Ideally, I'd ...
user avatar
3 votes
2 answers
2k views

Internal REST API versioning strategy

We are developing internal api's for integrating the server side logic (backend) with frontend (web, mobile etc). We have a java stack in our backend and front end is coded in react and react native. ...
user avatar
1 vote
1 answer
154 views

Objective-C: Strategy Pattern, is mainly by selector?

To use Strategy Pattern in Objective-C, I think it is mainly by selector. To omit if...else, use Objective-C runtime, convert string matching to choose selector (Strategy). Am my understanding ...
user avatar
  • 117
2 votes
1 answer
128 views

Looking for a strategy to ensure name of child node stays unique in collection

Even though I'm programming in PHP, I'm open to reviewing language-agnostic suggestions, as they might point me to valuable directions. To remove any possible confusion I feel some comments appear to ...
user avatar
1 vote
1 answer
136 views

Inheritance or strategy in my circular buffer

I've looked at some other threads but they don't quite answer my question, I think... I have a CircularBuffer object which I have separated from a ThreadSafeCircularBuffer object so that the CB logic ...
user avatar
  • 217
-2 votes
1 answer
56 views

What method/ approach is used to query a user's page on a website using backslash + username? [closed]

I am working on a Servlet/JSP project, the website have users and I need to display a user's profile using the notation myDomain.com/Joe instead of myDomain.com/users.jsp?user=Joe. An instance of my ...
user avatar
  • 107
0 votes
1 answer
255 views

How To: .Net periodic task to validate entries in tables

I am looking for a solution following best practices to simply periodically validate database entries against some business logic. For instance, I have the database with employees, and another table ...
user avatar
  • 127
14 votes
2 answers
10k views

What do I use as an alternative to Domain-Driven Design, if I cannot define a Competitive-Advantage area of my system to apply it?

From all I read and watch, Domain-Driven Design (DDD), is a costly and time-consuming endeavor. In fact, everyone I have seen, including Eric Evans and Greg Young, say, don't use DDD except where you ...
user avatar
  • 3,629
5 votes
1 answer
363 views

When can client code know about strategy pattern implementations?

I am considering using a strategy pattern for configuration file management, that way I can support some legacy configs. I feel pretty solid on the overall design (as its pretty standard strategy ...
user avatar
  • 133
0 votes
1 answer
437 views

For learning purposes, how should I set about implementing an arbitrary precision library in C or C++?

I know I am reinventing the wheel. But I'm really interested in implementing arbitrary precision numbers (integers, rationals, complex, etc) in C or C++ and their algorithms. Please be patient. My ...
user avatar
0 votes
1 answer
2k views

How to design a Rule Engine Validation System to be asynchronous and highly performant!

I am implementing a validation system which has some constraints, there are category of users let's say 30 and for each category there are number of rules. Actually there are 100 different rules. I ...
user avatar
  • 111
0 votes
3 answers
6k views

Strategy Pattern with abstract class instead of interface?

Is the strategy in the strategy pattern always an interface? What pattern would it be when the strategy is abstract?
user avatar
2 votes
2 answers
733 views

Best approach parsing input in multiple scenarios

I am developing an API that has one call that accepts a big JSON object. Based on this object, there are 10 possible parsing scenarios, i.e. if field xxxx.xxx is present, go with scenario 5. We ...
user avatar
  • 171
1 vote
1 answer
95 views

How to build visibility into a background worker service?

I have been working on a cloud-based background worker service, and regrettably it is almost "blind". What I mean by this is it is incredibly difficult to get any insight into what is going on, aside ...
user avatar
  • 1,103
3 votes
3 answers
686 views

Should you refactor all helper classes into small obects with state?

Imagine you want to have a room painted. You are the owner of this room and a Painter is capable of painting the room. There are different types of Painters: a BluePainter, a RedPainter etc. For every ...
user avatar
  • 1,722
3 votes
2 answers
4k views

Implementing strategy pattern multiple variables?

I am trying to implement Strategy Pattern for handling my content serialization and deserialization. So I have four kind of requests namely CREATE, RETRIEVE, UPDATE, DELETE and for each request I want ...
user avatar
3 votes
1 answer
149 views

What is the best serial port connection strategy

I am developing a program that polls a device for actvity. In the past I have always used a USB device with a pure USB device driver. The upside of this was that that device was blazingly fast. The ...
user avatar
  • 131
5 votes
2 answers
478 views

Does such a design pattern exist? (Multi-Strategy/Multi-Traits)

Is there a design pattern that would allow a class from a hierarchy to 'subscribe to' concrete methods? For example, say you have an abstract base class that requires the implementation of a method. ...
user avatar
  • 2,343
15 votes
2 answers
3k views

Zero Downtime Deployment - Transitional Db Schema

Achieving Zero Downtime Deployment touched on the same issue but I need some advice on a strategy that I am considering. Context A web-based application with Apache/PHP for server-side processing and ...
user avatar
3 votes
1 answer
773 views

Persistence Strategies - Filling a cache strategy

Let's say I have an interface IDataAccessObject<TSource> with CRUD methods to access a data source. I have an implementation StrategyDataAccessObject<TSource>, which uses an strategy ...
user avatar
2 votes
1 answer
647 views

Best Possible Way To Write Unit Tests For HTTP Middleware

I am using this go library(https://github.com/abourget/goproxy) to create a custom proxy server app. The app is utilizing several middleware of the following form: MyMiddlewarFunc(ctx *goproxy....
user avatar
  • 141
1 vote
0 answers
61 views

Strategies for creating a mobile site? [closed]

I'm looking for 2nd & 3rd opinions on a general mobile strategy for a website I work with. We have decided that tablets generally have an acceptable experience with our site (especially in ...
user avatar
  • 131
3 votes
3 answers
1k views

Why do we need a context class in strategy pattern?

For the strategy pattern, why do we need a context class to call the appropriate algorithm? Why can't we just do Strategy s = new OperationAdd()? This way, we still use polymorphism.
user avatar
17 votes
6 answers
10k views

Advantages of Strategy Pattern

Why is it beneficial to use the strategy pattern if you can just write your code in if/then cases? For example: I have a TaxPayer class, and one of its methods calculates the taxes using different ...
user avatar
2 votes
4 answers
387 views

Strategy pattern and "Is a" relationship

Imagine, I have class IAlgo which is an interface. I have derived from him and implemented his single method called matchCount in different implementations - AlgoA1, AlgoA2, AlgoA3, AlgoB1, AlgoB2. ...
user avatar
  • 1,073
2 votes
1 answer
236 views

Injection, strategies and OO

I'm working on refactoring a project. The business logic looks very much like using the Strategy pattern would be very beneficial, because depending on the values of three properties (let's say age, ...
user avatar
  • 1,527
2 votes
1 answer
891 views

Decorater pattern or strategy pattern

I'm constructing a c# serverside application and I'm trying to do this in a way it can easily be maintained aswell as extended if needed. So what we have is 4 different requests that need to be done (...
user avatar
  • 131
1 vote
1 answer
667 views

Should factory make context or concrete strategies objects in strategy-factory pattern?

In a typical strategy pattern class Strategy { public: virtual int execute() const = 0; } class StrategyA : public Strategy { public: int execute() const override; } class StrategyB : ...
user avatar
  • 239
3 votes
2 answers
4k views

Pattern for caching DAOs: strategy or decorator?

I'm building a php system with the Services/DAOs/Domain Models pattern, and now is the time to implement a caching system for the DAOs. Would you use a decorator pattern, or maybe the strategy ...
user avatar
  • 177
4 votes
1 answer
923 views

Creating/updating entity save strategy

Please note: although I'm talking about Java in this question, what I'm asking about here should really be language-agnostic. I am dabbling in OR/M for the first time, and have cooked up the ...
user avatar
  • 4,640
0 votes
1 answer
401 views

How to organize conversion logic for strategy pattern?

I have a Color class. It has a property model which is a class that implements ColorModel interface, this property could be a RGB, Hex or HSL classes which implementing ColorModel interface. // ...
user avatar
  • 156
0 votes
1 answer
134 views

How to compute data for charting?

I'm building a charting component that displays data directly from the raw data records. It should be able to filter data (subset) and then perform some rudimentry maths on the data (sum, avg, etc). ...
user avatar
1 vote
1 answer
390 views

Strategy vs Publiser-subscriber pattern

Let's say I have a channel endpoint where I receive messages. Because I want to process messages in a different way depending on its Header property, rather than create a massive switch I create ...
user avatar
3 votes
2 answers
414 views

Strategy game, how do I calculate the parallel actions?

I am building a strategy game where multiple units(5 - 20) fighting each other. I have a game logic that calculate all the actions that been done on each turn, and send it to the game engine to ...
user avatar
3 votes
2 answers
568 views

What do I gain by using the Strategy pattern in this case?

I wrote a program with Java that plays simple music. Currently chords have only one way ('strumming pattern') to be played. I want to expand this and create different 'strumming patterns' that chords ...
user avatar
  • 20.7k
0 votes
1 answer
910 views

MVC: Where should I store interchangeable algorithms used by the Model (whose names also need to be accessible to the View)?

Please consider a program, where the user chooses an algorithm from a list, and the Strategy pattern is utilized to set this algorithm as the model's operation. For example, an image procession ...
user avatar
  • 20.7k
0 votes
1 answer
135 views

Is it better to pass the whole object or use a setter?

Here is my initial code that I would like to modify by using strategy design pattern. class Bar { int a; int b; ... } Class Foo { Bar *bar; bool action1(){ // this function does a ...
user avatar
  • 123
1 vote
2 answers
2k views

Implementing a strategy pattern with dependency injection

Okay, so the goal here is to implement a strategy pattern that can be tested using any sort of automated testing tool. I've been struggling with this problem conceptually for a few weeks now and I ...
user avatar
  • 29