Strategy is a pattern of object behavior in design patterns, which mainly defines a series of algorithms and encapsulates them 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 the two algorithms, you can use strategy implementation.
Here, as an exa
Policy patterns define a series of algorithms, encapsulate each algorithm, and make them replaceable. The rule mode allows algorithms to change independently of customers who use it. (Original article: The Strategy Pattern Defines a family of algorithms, encapsulates each one, and makes them interchangeable. strategy lets the algorithm vary independently from clients that use it .) context (Application Scen
Webpage element center strategy _ (1) element horizontal center, center strategyHorizontal Center Scheme of In-row Elements
The row element is enclosed in a parent layer element whose display is block.text-align:centerYou can achieve
Code Implementation
Index.html
A horizontal center solution for block elements
Set the margin of a block to auto on the left and right. You can set the upper and lower margin as needed.{margin:0 auto}Code Implementation
Webpage element center strategy _ (2) vertical center of elements, center strategyVertical center of elements in a single row
Set the Row Height of the element in the row to the height of the parent element or the height of the package block to realize vertical center. For details, see the code.
Code Implementation
Index.html
Multi-row vertical center scheme of intra-row Elements
Let the package block simulate the table unit, and then usevertical-a
The rule mode is intended for a group
Algorithm , Encapsulate each algorithm into an independent class with a common interface, so that they can be replaced with each other. The policy mode allows the algorithm to change without affecting the client.
Suppose we want to design a shopping cart CAT System for e-commerce websites selling books. The simplest case is to multiply the unit price of all goods by the quantity, but the actual situation must be more complicated than that. For example,
/** * Strategy mode: For the same command (or behavior), different strategies to do different actions * Product Promotion * This class is: Cash Collection class * * @author Stone */public interface Icashsuper { Double Acceptcash (double money);}/** * Normal cash charge * @author Stone * */public class Cashnormal implements Icashsuper {@Overridepublic double acceptcash (double m Oney) {return money;}}/** * Discounted cash charge * @author Stone *
Liu Bei is about to marry his wife in Jiangdong. Zhuge Liang gave Zhao Yun (Best Man) three tips before, saying that they had taken the opportunity to solve the difficult problem. Hey, don't say that it really solved the big problem, in the end, Zhou Yu lost his wife and had a discount. Let's take a look at what the scene looks like.
Let's first talk about the elements in this scenario: three tips, one tip, and one Zhao Yun. The tips are given by Comrade Xiao Liang. They are placed in the tips,
Mode motiveThere are many different ways to accomplish a task, each of which is called a strategy, and we can choose different strategies to accomplish this task depending on the environment or the conditions.In software development also often encounter similar situation, to achieve a certain function has a number of ways, at this time can use a design mode to make the system can choose the solution flexibly, but also can easily add new solutions.In s
"Design pattern Refinement" Learning notes (10) ------Strategy (policy) mode
GoF : Define a series of algorithms, encapsulate them one by one, and allow them to replace each other. This mode allows the algorithm to vary independently from the customer who uses it.
For example, in our system, we need to paint a graphic or a WordArt (such a system is in the real world, a bill output system made by my former company has this function). If we need
Note: Table of Contents"oracle12c Performance Optimization strategy: Introduction Directory Table "Problem description
You've just started using the Oracle database and learned a few things about the various table types available. For example, you can spend choices between a heap organization table, an index organization table, and so on. You want to create a database app, and you need to determine the type of table it uses
Solution Solutions
The main content is about some notes and experiences when learning the design model.
Reference books available
Head first design patterns
Design Patterns: Elements of reusable object-oriented software
Implementation patterns.
The definitions of policy patterns in the two design patterns are the same: defining some column algorithms, encapsulating each algorithm, and making them interchangeable internally. The policy mode allows algorithms to change independently of users.Define a family of algor
Delete Sam file, clear Administrator account password
Find the password from the SAM file
1.l0phtcrack (LC)
2.LCP
3.SamInside Pro
Third, with net user command to restore the system login user password
Set up new password with password reset disk
V. Modify the screensaver file method
VI. Use software to modify passwords
Windows XP NT Password Recovery Key
Cleanpwd
Offline NT Password Registry Editor
Winternals Administrator ' s ERD Commander 2002/2003/2005
Force Change Windows2000 Local Administ
8.2.1 Strategy Design pattern (the strategy style)At run time, the policy pattern is useful if the application needs to choose between several algorithms, or between different parts of an algorithm. A common scenario is that when our application needs to perform several tasks, it is different only on very small sub-tasks. Using the policy mode, for the common part of the task, we just write once, plus param
When it comes to SEO, in fact, in addition to those cumbersome hair outside the chain of methods to increase the weight of the site to optimize the keyword, in fact, we can at the same time will be several not very effective strategies combined to use, and then constantly repeated testing, analysis, and finally come to the results, in the end Recently we found that the wheel chain plus Station group strategy, the effect is very good, such a
Vs 2008
A behavior of a class may have multiple implementation policies. You can extract this behavior and define it as an interface. Then, you can provide multiple implementations of this interface. These classes (Policies) can be replaced with each other without affecting the client.Code.
1. Mode UML diagram
2. Application
Examples of discounts for books are divided into general discount prices and gold discount prices. For book sellers, the two discounts are two strategies for selli
Policy mode: Behavioral modeThe same behavior, different processing algorithms are encapsulated separately. So they can replace each other.1. Define a super-type interface and behavior method2. Define different implementation classes and implement different algorithms for this behavior/** * Strategy mode: For the same command (or behavior), different strategies to do different actions * Product Promotion * This class is: Cash Collection class * *
Six AI elements required for wireless network strategy and ai elements for wireless network strategy
With the development of artificial intelligence (AI), organizations can transform their wireless networks through predictable, reliable, and measurable WiFi.
Today, artificial intelligence is everywhere. It is widely believed that artificial intelligence will become the next technology to subvert the indust
October 24 Aliyun 11 Ecological Carnival Grand Opening, the Aliyun storage products are also with the cloud storage of the various road housekeeping products to customers in good faith, double 11 to buy how to be more affordable, small series for everyone to solve the purchase of crude products introduction:
Strategy One: 10.24-11.10 filling value card • Enjoy back coupons • Smoking Awards
Double 11 preheating activity has officially opened the curt
Summary of some strategies of PHP program efficiency optimization, PHP Efficiency Strategy Summary
1. In the case of file_get_contents instead of file, fopen, feof, Fgets and other series of methods, try to use file_get_contents, because he is much more efficient! But pay attention to file_get_ Contents PHP version problem when opening a URL file; 2. As much as possible file operation, although PHP file operation efficiency is not low;3. Optimize 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.