Question

In: Computer Science

Briefly describe an example scenario where a strategy design pattern is suitable to use.

Briefly describe an example scenario where a strategy design pattern is suitable to use.

Solutions

Expert Solution

The pattern of strategy design is a kind of pattern of behavioural design that encapsulates a "family" of algorithms and selects one for use during runtime from the pool. The algorithms are interchangeable, which means they can be replaced by each other. The key concept is to create objects that represent different strategies. Such objects form a pool of approaches from which the background object may choose to modify its actions according to its approach. The same process is done by these objects(strategies), they have the same(single) task and write the same interface strategy.

For an example lets take sorting problem. To efficiently philtre an assortment of numbers, these algorithms have a set of rules unique to each other that they obey. For example consider the following;

  • Bubble Sort
  • Selection Sort
  • Linear Search
  • Merge Sort
  • Heap Sort

Then, we need various algorithms during execution in our software. Using strategy design pattern enables us to group these algorithms and, as appropriate, pick from the pool.


Related Solutions

Explain an example of a scenario where a firm might use the Pareto diagram to focus...
Explain an example of a scenario where a firm might use the Pareto diagram to focus on the largest causes of quality failures in their organization (IN YOUR OWN WORDS). Provide an example(s).
Describe a scenario/design where a polymorphic behavior is utilized. In the lecture this week we studied...
Describe a scenario/design where a polymorphic behavior is utilized. In the lecture this week we studied an example in which we defined a GeometricObject as the base class and added features to this base class to define two specialized classes, namely the Circle and the Rectangle classes. Your design should have the design elements of the example we studied but it doesn’t have to be related to geometric shapes. Clearly list the functions in the base class you would declare...
Can you give a java code example of using a singleton pattern and factory pattern design...
Can you give a java code example of using a singleton pattern and factory pattern design together?
or each of the design patterns listed below, briefly discuss the purpose of that pattern and...
or each of the design patterns listed below, briefly discuss the purpose of that pattern and explain how its use contributed to the code you developed for your Maze Game in Assignment 2. Your explanation should provide specific examples from your game that illustrate the function performed by the implementation of each pattern. a)      Command Pattern b)      State Pattern c)      Singleton Pattern
[Design Pattern] Think of a scenario that can be solved using all of these 3 patterns...
[Design Pattern] Think of a scenario that can be solved using all of these 3 patterns - Strategy, Factory and Abstract Factory patterns. 1. Write the Scenario 2. Write the code for the 3 patterns 3. Create the UML diagram
Describe strategies of distribution in service organization with a suitable example.
Describe strategies of distribution in service organization with a suitable example.
Part 1: Product Strategy Youth Program Briefly describe your product or service. Where is it in...
Part 1: Product Strategy Youth Program Briefly describe your product or service. Where is it in the product development life cycle? What recommendations do you have for improving the offering to fit your target market’s needs? Be sure to consider the following: What level of quality and consistency does the offering have? How many features does it have and can they be removed or added? Does the design and/or service deliver what the customer values? If not, how can it...
What are the three aspects of research design? Use one research paper as example to briefly...
What are the three aspects of research design? Use one research paper as example to briefly explain the three aspects of research design in this research paper.
3. Describe a scenario where the Spearman correlation would be appropriate to use in calculating the...
3. Describe a scenario where the Spearman correlation would be appropriate to use in calculating the strength of the relationship between two variables. Identify the variables and explain the rationale for your answer. What makes this scenario different from the scenario in the previous question?
Describe a scenario where the Pearson correlation would be appropriate to use in calculating the strength...
Describe a scenario where the Pearson correlation would be appropriate to use in calculating the strength of the relationship between two variables. Identify the variables and explain the rationale for your answer.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT