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 [strategy]

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

11
votes
2answers
435 views

How do you deal with comprehending 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 ...
0
votes
1answer
29 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/...
0
votes
2answers
113 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. ...
6
votes
4answers
719 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, ...
2
votes
2answers
145 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 ...
2
votes
2answers
381 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. ...
0
votes
0answers
99 views

How to implement strategy pattern in context of few key elements on every page?

This is my concern: I need to generate content for <title> <h1> and <meta name="description"> tags, that will affect ~ 100 000 pages. Basically, it is a SEO optimization. ...
0
votes
1answer
75 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 ...
3
votes
1answer
119 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 ...
1
vote
1answer
108 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 ...
-2
votes
1answer
54 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 ...
0
votes
1answer
126 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 ...
4
votes
1answer
2k 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 ...
5
votes
1answer
172 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 ...
0
votes
1answer
219 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 ...
0
votes
1answer
1k 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 ...
0
votes
3answers
2k 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?
2
votes
2answers
375 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 ...
1
vote
1answer
91 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 ...
3
votes
3answers
389 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 ...
2
votes
2answers
1k 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 ...
4
votes
1answer
117 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 ...
4
votes
2answers
274 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. ...
13
votes
2answers
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 ...
3
votes
1answer
494 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 ...
2
votes
1answer
159 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....
1
vote
0answers
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 ...
3
votes
3answers
654 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.
15
votes
6answers
6k 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 ...
2
votes
4answers
314 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. ...
2
votes
1answer
216 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, ...
2
votes
1answer
550 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 (...
1
vote
1answer
392 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 : ...
3
votes
2answers
2k 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 ...
4
votes
1answer
837 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 ...
0
votes
1answer
225 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. // ...
0
votes
1answer
122 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). ...
0
votes
1answer
199 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 ...
3
votes
2answers
295 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 ...
3
votes
2answers
382 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 ...
0
votes
1answer
633 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 ...
0
votes
1answer
131 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 ...
1
vote
1answer
1k 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 ...
1
vote
2answers
274 views

Inheritance vs 'specification' by fields

I'm currently reading 'Head first design patterns' and I already have a few questions on the first chapter of the book. This chapter introduces the 'prefer composition over inheritance' design ...
1
vote
1answer
324 views

Image strategy on Android

I am creating an application with lots of photos. They will take > 100 mb on memory. So far I have 3 ideas: Place it in @drawable - app will be heavy Download by JSON and place in java ...
0
votes
2answers
941 views

Strategy with using SVN to switch between test and production server. (with maintaining configuration files) [closed]

I would like to know your opinion about my setup right now, how I do things with SVN and if you could find some better solution for me. I'd appreciate it very much if someone could come up with some ...
9
votes
2answers
5k views

Is context inheritance, as shown by Head First Design Patterns' Duck example, irrelevant to strategy pattern?

In Head First Design Patterns it teaches the strategy pattern by using a Duck example where different subclasses of Duck can be assigned a particular behavior at runtime. From my understanding the ...
2
votes
2answers
381 views

Best strategy in SQL

Recently, a colleague told me that it wasn't advisable to make conditions in the join clauses. Instead he suggested to make conditions in the where clause. He told me that the SQL engine was optimized ...
0
votes
1answer
183 views

How to handle “animated” game where the visual should “animate” instead of abruptly change?

I've been playing around and learning javascript/KineticJS by making some simple games (think like board games). I have the game model that is relatively logically simple. When a "move" is given to ...
0
votes
1answer
236 views

Do integrated systems increase development time and cause inflexibility?

I work for a large financial company that manages money for thousands of clients. This company has very complex business processes and they operate in a very dynamic environment. This is a fairly ...