Professional Documents
Culture Documents
Strategy Design Pattern
Strategy Design Pattern
StrategyDesignPattern
Strictly as per the compliance and regulations of:
© 2014. Mrs. Renu Bala & Mr. Kapil Kumar Kaswan. This is a research/review paper, distributed under the terms of the Creative
Commons Attribution-Noncommercial 3.0 Unported License http://creativecommons.org/licenses/by-nc/3.0/), permitting all non-
commercial use, distribution, and reproduction inany medium, provided the original work is properly cited.
Strategy Design Pattern
Mrs. Renu Bala α & Mr. Kapil Kumar Kaswan σ
Abstract- Design patterns usually describe abstract systems of experience as they systematically name, explain and
interaction between classes, objects, and communication evaluate important and recurrent designs in software
flows. So, a description of a set of interacting classes that systems. They describe problems that occur repeatedly,
provide a generalized solution framework to a and describe the core of the solution to that problem, in
generalized/specific design problem in a specific context can
such a way that this solution can be used many times in
Year 2014
be said as a design pattern. There are many design patterns
that can be used to solve real-life problems, but it remains very different contexts and applications. A good design is a
difficult to design, implement and reuse software for complex good solution regardless of the technology. And no
applications. Examples of these include enterprise system, matter how good the technology may be, it is only as
real-time market data monitoring and analysis system. Design good as its design, and specifically the implementation 35
patterns provide an efficient way to create more flexible, of that design. In fact, a great design with older
elegant and ultimately reusable object-oriented software. Each technology may still be good, but a bad design with new
A
Framework has two main components: the common
design pattern is a generic solution that has been language runtime and the .NET Framework class library.
observed in multiple instances to help resolve a The common language runtime is the foundation of the
particular problem within a known context. Design .NET Framework [2]. The .NET Framework is designed
patterns provide an efficient way to create more flexible, to fulfill the following objectives:
elegant and ultimately reusable object-oriented
software. Design methods are supposed to promote • To provide a consistent object-oriented program -
good design, to teach new designers how to design well ming environment whether object code is stored
and to standardize the way designs are developed. and executed locally, executed locally but
Typically, a design method comprises a set of syntactic Internet-distributed, or executed remotely.
notations usually graphical and a set of rules that govern • To provide a code-execution environment that
how and when to use each notation. It will also describe minimizes software deployment and versioning
problems that occur in a design, how to fix them, and conflicts.
how to evaluate a design. Each pattern describes a • To provide a code-execution environment that
problem which occurs over and over again in our promotes safe execution of code, including code
environment, and then describes the core of the solution created by an unknown or semi-trusted third
to that problem, in such a way that you can use this party.
solution a million times over, without ever doing it the • To provide a code-execution environment that
same way twice [1]. The solutions of the given problems eliminates the performance problems of scripted
are expressed in terms of objects and interfaces. Design or interpreted environments.
patterns are being increasingly used in software design. • To make the developer experience consistent
Design patterns are a good means for recording design across widely varying types of applications, such
as Windows-based applications and Web-based
Author α σ: Department of Computer Science and Application applications.
Chaudhary Devi Lal University Sirsa, Haryana, India.
e-mails: renubala.gghsodhan@gmail.com,
• To build all communication on industry standards software design pattern that enables an algorithm's
to ensure that code based on the .NET behavior to be selected at runtime. The strategy pattern
Framework can integrate with any other code [2]. • defines a family of algorithms,
• encapsulates each algorithm, and
III. Strategy Pattern
• makes the algorithms interchangeable within that
Strategy - defines an interface common to all supported family.
algorithms. Context uses this interface to call the algor - Strategy lets the algorithm vary independently
ithm defined by a ConcreteStrategy. from clients that use it. Strategy is one of the patterns
ConcreteStrategy - each concrete strategy implements included in the influential book Design Patterns by
an algorithm. Gamma et al. that popularized the concept of using
Year 2014
ConcreteStrategy that should be used. When an radically different validation to be performed. The
operation is required then the algorithm is run from the validation strategies, encapsulated separately from the
strategy object. The Context is not aware of the strategy validating object, may be used by other validating
implementation. If necessary, addition objects can be objects in different areas of the system (or even different
defined to pass data from context object to strategy. systems) without code duplication.The essential
The context object receives requests from the requirement in the programming language is the ability
client and delegates them to the strategy object. Usually to store a reference to some code in a data structure
the ConcreteStrategy is created by the client and and retrieve it. This can be achieved by mechanisms
passed to the context. From this point the clients such as the native function pointer, the first-class
interact only with the context. In other words, it defines a function, classes or class instances in object-oriented
family of algorithms, encapsulate each one and make programming languages, or accessing the language
them interchangeable. In computer programming, the implementation's internal storage of code via reflection.
strategy pattern also known as the policy pattern is a
Global Journal of Computer Science and Technology ( c
Structure
Year 2014
stating nine essential pattern elements. These patterns
the connection between design patterns and software
element describes the design patterns effectively; also
maintainability. It is very hard to understand better what
describe how these patterns are useful to solve the
the patterns are and how they relate to each other. At
problem. Industrial applications typically require different
this point there is a fundamental picture as reacting to 37
kinds of interfaces to the data they store and the logic
an event to produce accounting entries. We used our
they implement are data loaders, user interface and
probabilistic quality model for estimating the mainta-
38
D ) Volume XIV Issue VI Version I
Global Journal of Computer Science and Technology ( c