JS and design pattern ------ Strategy pattern StrategyI. general summary 1. I talk about the policy mode, also known as the algorithm cluster mode, which defines different algorithms and can replace them with each other, this mode makes the algorithm changes independent of the customers who use the algorithm. The policy mode is similar to the factory mode. The policy mode is relatively simple and easy to un
understanding of technology, do not tangle with the product implementation methods.
ØEncourage storytelling:Stories are the best way to help designers understand users.
ØAvoid induced problems:Typical induction problem: Will you use this function? In general, the user will give a meaningless positive answer.
I borrowed this book from Zhe tu, but I found that《About face 2.0"And, of courseChinese TranslationAlso, I borrowed a copy of it. I have never read this book similar to the industry bible,
Recently, I want to buy a few books on. NET and design patterns, just csdn on the Dearbook on the next, finishing a few of these more classic books. Some of the English versions of the books cannot be found inside. The price refers to the non-VIP members of the prices, that is, ordinary members of the price.Microsoft.
conditional statements, the code will be easier to manage, and future maintenance of the code will be much easier.
The goal now is to refer these validation checks to various policy classes so that they can be reused in proxy methods and other methods. Each validation takes the input value out of the text box, validates it according to the policy that is required by H, and returns a bool value. If the return fails, a Nserror instance is also returned. The returned nserror can explain the caus
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 str
provide a "free to switch" policy.Avoid using multiple criteria to judge---> If there is no policy model, what would it look like? A strategy family has 5 strategy algorithms, one will use a strategy, one will use B strategy, how to design it? Multiple conditional statement
For Java programmers, mastering object-oriented design theory and some design patterns is an essential skill. To start programming without learning a theory is similar to learning a language without studying the alphabet. There's a lot of object-oriented theory, design patterns and best practices on the market, but only a few
Design Mode (11) Strategy Mode
I. Discounts
A website that sells books wants to build a settlement system. Part of the system is to calculate the price of books. The books on this website are basically discounted, and the discounts for different types of
For. NET software
Several books recommended by design/Development Engineer
List several books that have had a big impact on me over the past year. Thanks to the authors and translators who have helped me with these books. Thank you for your hard work. I hope these books w
Http://product.china-pub.com/192981
Splendid blueprint: how to plan a memorable website (version 2nd) online reading of e-books
This book is a new version of the best-selling book on information architecture. The author tells you how to plan easy-to-use websites and the information architecture principles behind them easily. This book first introduces the eight basic principles for establishing an information architecture, then emphasizes the role o
I. Strategy ModeThe rule mode is intended for a group of algorithms,Encapsulate each algorithm into an independent class with a common interfaceSo 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 si
) {//TODO auto-generated Method Stub intN=0; intN=0; intM=0; Scanner S=NewScanner (system.in); System.out.print ("Please enter the number of the book you want to buy:"); N=S.nextint (); if(n%5==3) {n=n/5; M=n%5; if(n==0) {System.out.println ("The lowest price the reader buys for a batch of books is:" + (3*8*0.9)); } Else{System.out.println ("The lowest price for readers to buy a batch of
tax" there are different methods of tax calculation. ----WIKIPEDIAPersonal understandingThe strategy model can be seen from the name, there are a variety of options, different strategies correspond to different implementations, then the general form for an interface to adopt a variety of implementations (that is, to provide a different strategy), and then provide a choice of a policy class can be defined:
Many friends asked to learn design patterns of books, eldest brother Canglang in the FAQ there is a short narrative, here I extend, said that they have seen or turned over the design patterns of books, due to the level of limitations, there must be a wrong place, I hope you correct, if you see a good pattern related
, then the system should be designed to help the user remember, or not to be remembered by the user at all.The impact of recognition and memory on design1. It is easier to see and choose than to recall and enter.2, as far as possible to use images to express functions, such as today's user interface often use images to express the function3, as little text, less people to readUse of the Pop-up dialog box:The Pop-up dialog box lets the user stop the original path and turn their attention here. Th
Books explaining database table design solutions have found that the biggest bottleneck for websites is the rationality of database table design. Please recommend books on this topic. Preferably related to mysql ., High-Performance MySQL Performance Tuning and architecture design
specific policy classes.
specific policy (concretestrategy) Role: wraps the associated algorithm or behavior.
code example:
Environment Role Class:
public class Context {
//The object that holds a specific policy
private strategy strategy;
/**
* constructor, passing in a specific policy object
* @param strategy specific policy Object
24-day design model-strategy model, 24-day Design Model
Original works of Lin bingwen Evankaka. Reprinted please indicate the source http://blog.csdn.net/evankakaI. Stragegy Pattern 1. Introduction
The Strategy Mode is also called the rule mode. It encapsulates a series of algorithms and defines an abstract algorithm i
12{"Headfirst design mode" strategy mode}3{the class in this unit is a policy class}4{compiler tool: Delphi7.0}5{e-mail: [Email protected]}67unit Ustrategy;89interface1011type12 {Flight interface, and its implementation class}13Iflybehavior = Interface (iinterface)Procedure Fly;The end;17Tflywithwings = Class (Tinterfacedobject, Iflybehavior)PublicProcedure Fly;The end;22Tflynoway = Class (Tinterfacedobject
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.