Global Information Lookup Global Information

Strategy pattern information


In computer programming, the strategy pattern (also known as the policy pattern) is a behavioral software design pattern that enables selecting an algorithm at runtime. Instead of implementing a single algorithm directly, code receives runtime instructions as to which in a family of algorithms to use.[1]

Strategy lets the algorithm vary independently from clients that use it.[2] Strategy is one of the patterns included in the influential book Design Patterns by Gamma et al.[3] that popularized the concept of using design patterns to describe how to design flexible and reusable object-oriented software. Deferring the decision about which algorithm to use until runtime allows the calling code to be more flexible and reusable.

For instance, a class that performs validation on incoming data may use the strategy pattern to select a validation algorithm depending on the type of data, the source of the data, user choice, or other discriminating factors. These factors are not known until runtime and may require radically different validation to be performed. The validation algorithms (strategies), encapsulated separately from the validating object, may be used by other validating objects in different areas of the system (or even different systems) without code duplication.

Typically, the strategy pattern stores a reference to code in a data structure and retrieves it. This can be achieved by mechanisms such as the native function pointer, the first-class function, classes or class instances in object-oriented programming languages, or accessing the language implementation's internal storage of code via reflection.

  1. ^ "The Strategy design pattern - Problem, Solution, and Applicability". w3sDesign.com. Retrieved 2017-08-12.
  2. ^ Eric Freeman, Elisabeth Freeman, Kathy Sierra and Bert Bates, Head First Design Patterns, First Edition, Chapter 1, Page 24, O'Reilly Media, Inc, 2004. ISBN 978-0-596-00712-6
  3. ^ Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides (1994). Design Patterns: Elements of Reusable Object-Oriented Software. Addison Wesley. pp. 315ff. ISBN 0-201-63361-2.{{cite book}}: CS1 maint: multiple names: authors list (link)

and 24 Related for: Strategy pattern information

Request time (Page generated in 0.8241 seconds.)

Strategy pattern

Last Update:

In computer programming, the strategy pattern (also known as the policy pattern) is a behavioral software design pattern that enables selecting an algorithm...

Word Count : 970

Strategy

Last Update:

actions. A strategy describes how the ends (goals) will be achieved by the means (resources). Strategy can be intended or can emerge as a pattern of activity...

Word Count : 3108

State pattern

Last Update:

state pattern can be interpreted as a strategy pattern, which is able to switch a strategy through invocations of methods defined in the pattern's interface...

Word Count : 568

Behavioral pattern

Last Update:

modules, and implement complex, non-deterministic control strategies Chain-of-responsibility pattern Command objects are handled or passed on to other objects...

Word Count : 430

Provider model

Last Update:

existing strategy pattern, and that this should, therefore, be the preferred terminology for describing the design pattern at hand. Strategy pattern "The...

Word Count : 272

Null object pattern

Last Update:

regarded as a special case of the State pattern and the Strategy pattern. It is not a pattern from Design Patterns, but is mentioned in Martin Fowler's Refactoring...

Word Count : 2801

Template method pattern

Last Update:

designer) Adapter pattern Strategy pattern Gamma, Erich; Helm, Richard; Johnson, Ralph; Vlissides, John (1994). "Template Method". Design Patterns. Addison-Wesley...

Word Count : 1151

Bridge pattern

Last Update:

resize_by_percentage(2.5) print(shape.draw()) BridgePattern.test() Adapter pattern Strategy pattern Template method pattern Gamma, Erich; Helm, Richard; Johnson, Ralph;...

Word Count : 1905

Dependency injection

Last Update:

description language Factory pattern Inversion of control Plug-in (computing) Strategy pattern AngularJS Service locator pattern Parameter (computer programming)...

Word Count : 3452

Software design pattern

Last Update:

In software engineering, a design pattern describes a relatively small, well-defined aspect (i.e. functionality) of a computer program in terms of how...

Word Count : 2802

Chart pattern

Last Update:

A chart pattern or price pattern is a pattern within a chart when prices are graphed. In stock and commodity markets trading, chart pattern studies play...

Word Count : 437

Strategic management

Last Update:

as pattern – a consistent pattern of past behavior, with a strategy realized over time rather than planned or intended. Where the realized pattern was...

Word Count : 14878

Composition over inheritance

Last Update:

Delegation pattern Liskov substitution principle Object-oriented design Object composition Role-oriented programming State pattern Strategy pattern Freeman...

Word Count : 1939

Strategy game

Last Update:

A strategy game or strategic game is a game (e.g. a board game) in which the players' uncoerced, and often autonomous, decision-making skills have a high...

Word Count : 1405

Offensive programming

Last Update:

discoverable by failing unit tests. Remove shortcut code (see the strategy pattern): A simplified code path may hide bugs in a more generic code path...

Word Count : 399

Pattern recognition

Last Update:

Pattern recognition is the task of assigning a class to an observation based on patterns extracted from data. While similar, pattern recognition (PR) is...

Word Count : 4255

Southern strategy

Last Update:

In American politics, the Southern strategy was a Republican Party electoral strategy to increase political support among white voters in the South by...

Word Count : 14200

Strategy video game

Last Update:

quite large in some games, and 4X strategy games are known for having the largest. A build order is a linear pattern of production, research, and resource...

Word Count : 6368

Service locator pattern

Last Update:

The service locator pattern is a design pattern used in software development to encapsulate the processes involved in obtaining a service with a strong...

Word Count : 574

Strategy dynamics

Last Update:

strategy, and is used in two distinct, though equally important senses. The dynamics of strategy and performance concerns the ‘content’ of strategy –...

Word Count : 2948

Reactor pattern

Last Update:

software design pattern is an event handling strategy that can respond to many potential service requests concurrently. The pattern's key component is...

Word Count : 1481

Functional programming

Last Update:

Many object-oriented design patterns are expressible in functional programming terms: for example, the strategy pattern simply dictates use of a higher-order...

Word Count : 8445

Inversion of control

Last Update:

Observer pattern Publish/subscribe Service locator pattern Signal (computing) Software framework Strategy pattern User exit Visitor pattern XSLT Sweet...

Word Count : 1474

Entity component system

Last Update:

other domains.[example needed] Model–view–controller Observer pattern Strategy pattern Relational model To avoid ambiguity in this article, we follow...

Word Count : 1740

PDF Search Engine © AllGlobal.net