1. Scenario Simulation
Simple quotation management system:Full price for common and new users5% discount for old customers10% discount for major customers2. No mode solution
Package demo16.strategy. example2;/*** price management, mainly used to calculate the price quoted to the customer */public class price {/***. For different types, calculate different prices * @ Param goodsprice original sales price * @ Param customertype customer type * @ return
Transferred from: http://www.cnblogs.com/java-my-life/archive/2012/05/10/2491891.htmlIn the book "Java and Patterns" of Dr. Shanhong, this describes the strategy (strategy) Pattern: The policy mode belongs to the behavior pattern of the object. It is intended for a set of algorithms that encapsulate each algorithm in a separate class with a common interface, so that they can be replaced with each other. Th
The policy mode belongs to the behavior pattern of the object. It is intended for a set of algorithms that encapsulate each algorithm in a separate class with a common interface, so that they can be replaced with each other. The policy pattern allows the algorithm to change without affecting the client.Structure of the policy patternThe strategy pattern is the wrapper over the algorithm, which separates the responsibility of the algorithm and the algo
Objective
Just worked overtime, eh, the company stipulated that usually overtime only 10 dollars of meal supplement, Saturday and Sunday overtime, only to give a series of leave, in the state-mandated holidays in accordance with 3 times times the wages issued. So for so many ways to calculate overtime, the company's OA system is how to do it? This is going to be about the strategy design pattern I've summed up here today.
Policy mode
In Gof's desig
Original address: http://www.cnblogs.com/java-my-life/archive/2012/05/10/2491891.html The policy mode belongs to the behavior pattern of the object. It is intended for a set of algorithms that encapsulate each algorithm in a separate class with a common interface, so that they can be replaced with each other. The policy pattern allows the algorithm to change without affecting the client.structure of the policy patternThe strategy pattern is the wrapp
1. Definition
Policy mode: Defines a set of algorithms that encapsulate each algorithm so that they can be replaced with each other. The policy pattern allows the algorithm to change independently of the client that calls it. The policy pattern enables this set of algorithms to
change when the client calls them.
2. There are three characters in the strategy mode
(1) abstract strategy
One talk about the search engine optimization strategy, basically can be divided into two kinds: one is to search engine as an imaginary enemy, try to conquer it, a kind of the enemy as a friend, as a strategic partner for optimization. Hangzhou SI billion Network Technology Co., Ltd. generally advocated by the search engine to make friends with the strategy, in fact, both strategies can become an effective
Intent
Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from the clients that use it.
Capture the specified action in an interface, bury implementation details in derived classes.
Problem
One of the dominant strategies of object-oriented design is the "open-closed principle ".
Figure demonstrates how this is routinely achieved-encapsulate interface details in a base c
Strategy is a pattern of object behavior in design mode, mainly defining a series of algorithms that encapsulate these algorithms into separate classes.Stratrgy application is more extensive, for example, the company business Change chart, there may be two ways to achieve, one is the line curve, one is the Block Diagram (bar), which is two algorithms can be implemented using strategy.Here, for example, a string substitution, there is a file that we ne
#coding: Utf-8 ' strategy mode: is the use of multiple algorithms to solve a problem, the most important feature is the ability to transparently switch the algorithm at runtime (client-side code is not aware of change) If there are two algorithms, one for a small amount of input effect, and the other for a lot of input, then you can use the policy mode at run time based on the input data to decide which algorithm to use to think or to cite an examp
Table policy (Table strategy)
In this strategy, the persistence engine (persistence engine) uses a table in a relational database to generate the primary key. This strategy portability is better because all relational databases support this strategy. Different Java EE application servers use different persistence engi
launch plan To achieve the company's goals. Strategy is a set of tactics, it is above the tactical, but not out of the tactical, it directs the tactics, the tactics assists it to succeed.
A very simple example of the launch strategy: the same project, a daily consumption of 50,000 yuan and a month to spend 50,000 yuan, how would you vote separately? You can think about it according to the project you are
Hello everyone, I am a just contact SEO novice webmaster soon. I recently in the operation of the giant Amoy customer network projects, encountered a lot of problems, found that according to those so-called SEO Master said some things, I did not see after the implementation of what effect, is now trying to find their own SEO personalized coping strategies. I think the best way to improve SEO skills is to encounter a problem, after referring to Baidu search s
Policy mode (stragety pattern)
The strategy pattern is a behavioral pattern, which defines a series of algorithms, encapsulates each algorithm, and allows them to replace each other, allowing the algorithm to change independently of the customer using it.
Using the policy model, you can separate behavior from the environment. The Environment class is responsible for maintaining and querying the behavior classes, and the various algorithms are provid
Role:
Define a series of algorithms that encapsulate them one by one and make them interchangeable. This mode allows the algorithm to be independent of the client that uses it.
Analytical:
In short, the strategy pattern is the encapsulation of an algorithm. When dealing with a problem there may be a variety of algorithms, the interface of these algorithms (input parameters, output parameters, etc.) are consistent, then you can consider using the
In the previous article, we analyzed three reasons for the gap between strategy and BPM: No detailed description and decomposition strategy, no governance of the implementation strategy, no measurement strategy. Bridging the gap requires the following three areas of work, namely, the elaboration and decomposition of st
From
The policy mode belongs to the behavior pattern of the object. It is intended for a set of algorithms that encapsulate each algorithm in a separate class with a common interface, so that they can be replaced with each other. The policy pattern allows the algorithm to change without affecting the client.
The strategy pattern is the wrapper over the algorithm, which separates the responsibility of the algorithm and the algorithm itself, delegati
It is important to back up your database if your database tables are missing or corrupted. If a system crash occurs, you will want to be able to recover as few data from your table as possible to the state at which the crash occurred. This paper mainly on the MyISAM table to do backup recovery.
Backup strategy One: Copy database files directly (not recommended)
Backup strategy Two: Use Mysqlhotcopy backup
ConceptThe policy pattern defines a series of algorithms, encapsulates each algorithm, and allows them to be replaced with each other. The policy model allows the algorithm to be independent of the customer using itChanges in the state. (Original: The Strategy Pattern defines a family of algorithms,encapsulates each one,and makesthem interchangeable. Strategy lets the algorithm vary independently from clien
Bridging (bridge) mode is one of the structural patterns, while the policy (strategy) pattern belongs to the behavior pattern. The following are their UML structure diagrams.
Bridge mode:Policy mode:In bridging mode, abstraction refers to implementor by aggregation. Give an example:
Policy mode: I want to draw a circle, a solid circle, I can use Solidpen to configure, draw a dashed circle can be configured with Dashedpen. This is the
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.