Questions tagged [strategy-pattern]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
10
votes
5answers
2k views

Can we completely replace inheritance using strategy pattern and dependency injection?

For example: var duckBehaviors = new Duckbehavior(); duckBehaviors.quackBehavior = new Quack(); duckBehaviors.flyBehavior = new FlyWithWings(); Duck mallardDuck = new Duck(DuckTypes.MallardDuck, ...
2
votes
2answers
164 views

Strategy pattern and different implementation

I am still learning Design Patterns and I have a situation in my hand. I am developing a simple employee management Python program. An employee can be a Developer, Senior Developer, Lead Developer, ...
2
votes
2answers
185 views

Strategy/domain object responsibilities

Assume we are in the world of car rental application :) Let's say that I have 3 types of cars with 2 categories of price: Car type Price category ------------------------------ Sport ...
3
votes
2answers
547 views

DDD - delegate business rule of domain object to external service

Situation: I am implementing DDD in my first project and I would like to clarify how to correctly implement strategy pattern (in my case check if API token is active). This is a business rule of ...
2
votes
2answers
160 views

How to implement Strategy pattern for combined behaviours

Strategy pattern solves the necessity of applying a certain algorithm/behaviour depending on the object's type itself. So you can iterate over a bunch of similar objects and call the same function ...
1
vote
3answers
196 views

Strategy Pattern and inheriting boilerplate functionality

I've read that when using the Strategy Pattern, you should stick to composition rather than inheritance. But does this mean that any inheritance at all is bad practice? If there is functionality to be ...
1
vote
2answers
907 views

Implementing strategy pattern via configuration

In my current problem domain, a number of problems seem to lend themselves quite well to the strategy pattern. I have a common, high-level process - let's say it's a sales process - and regardless of ...
2
votes
1answer
986 views

Does my use of the strategy pattern violate the fundamental MVC pattern in iOS?

I'm about to use the 'strategy' pattern in my iOS app, but feel like my approach violates the somehow fundamental MVC pattern. My app is displaying visual "stories", and a Story consists (i.e. has @...