5 permit 12.1.2.0/30 (external line two routes)!Route-map Redis_conn Permit 10Match Interface serial1/0 SERIAL1/1Route-map Dist_out2 Permit 10Match IP address prefix-list dist_out2!Route-map Line2 Permit 10Match IP address prefix-list line2!Route-map line1 Permit 10Match IP address prefix-list line1!ISP (R2) Config: (ISP configuration is very simple, basically do nothing, actually, the user has what needs, preferably in the CE above, PE on the requirements to meet the situation, as far as possi
Wiredquackbehavior:iquack {public string duckquack () {return "It ' s sounds like Wired annimal"; }} public class Cantquackbehavior:iquack {PubliC String Duckquack () {return "no sounds"; }} public class Duck {IFLY F; Iquack Quack; Public Duck () {f = new normalfly ();//The algorithm required to instantiate in the constructor quack = new Quackbehavior (); } public void Setfly (IFLY fly) {f = fly;//dynamically set the required algorithm} public string Duckfly (
Brief introduction
The policy pattern defines the algorithm families, which are encapsulated separately so that they can be replaced by each other. This pattern allows the algorithm to be independent of the client using it and change independently.
Composition
Abstract policy role: A policy class, usually implemented by an interface or abstract class.
Specific policy role: wrapping the relevant algorithms and behaviors.
Environment role: holds a reference to a policy class that is eventually cal
TheStrategyPattern is a designPattern to encapsulate the variants (algorithms) and swap them strategically to alter system behavior without changing its architecture. According to gof,StrategyPattern is intended,Define a family of algorithms, encapsulate each one, and make them interchangeable.Strategy lets the algorithm vary independently from clients that use it.
StrategyPattern has three participant ipants that includeStrategy, concreteStrategy and context.
From: NetEase Cloud classroom-hit-Q teacher1. Violence AestheticsQuestion 1: The problem of the satisfaction of Boolean expressions (NP-complete problems)Solution 1. The complexity of time is 2^n.question 2.8 Puzzle questionSolution 2. Convert to tree search problem, generate solution space for possible moving resultsQuestion 3: Hamiltonian ring Problem (NP complete problem)Solution 3. From the origin, generate the solution space for the points that may be accessed, and from each accessible poin
is the root of the sub-tree is the solution of the problem, if not contain the solution of the problem, then discard the subtree of the search, back to the upper parent node, Continue to the next deep-first search process.In backtracking, it is not a priority to construct the whole state space tree, then search, but in the search process, gradually constructs a state space tree, that is, edge search, edge construction.Use of backtracking methods:(1). Determine the problem state structure;(2). A
Policy mode:
A policy pattern is an object's behavior pattern, intended to encapsulate a set of algorithms. Dynamically select the desired algorithm and use it.
A strategy pattern refers to a pattern in a program that involves decision control. The policy pattern is very powerful because the core idea of the design pattern itself is the idea of the object-oriented programming of multiple forms.
! Income = 4500.00,tax = 30.0000! Income = 1986.00,tax = 0.0000!
Advantages:
1, the hierarchy structure of the policy class defines an algorithm or a behavior family, the proper use of inheritance can move the common code into the parent class, thus avoiding duplicate code;2, inheritance can handle a variety of algorithms or behavior, you can avoid the use of multiple conditional transfer statements.
Disadvantages:
1, the client must know all the policy classes, and decide which policy class to
Recently, Baidu's strategy update, let the Internet on a "focus on the content of the construction" of the voice, Webmasters began to discuss how to build a good site, how the site design to feed the spider's appetite? Small series is also studying how to surprise the website design, in order to cater to the new Baidu strateg
algorithm realization.Application Scenarios:1, multiple classes only differ in performance behavior, you can use the Strategy mode, at run time to dynamically select the specific behavior to execute.2. Different strategies (algorithms) need to be used in different situations, or strategies may be implemented in other ways in the future.3, the customer hides the specific strategy (algorithm) Implementation
becomes a duplication, the code will have a lot of duplication. A little better. The check code will be sorted and encapsulated, and there will be more duplicate copies.
2. If I want to add an input validation, then directly modify the Submit function, the function will be significantly bloated, and is to destroy the "open and close" principle.
3. If you modify the Submit function, you must cover the test of the function design, because you do not
The so-called "all roads lead to Rome", in reality, in order to achieve a certain purpose is often not only one way. For example, earn money to support the family: can do a little business, can play a division of labor, and even can be stolen, Rob, gambling and other means. In programming language design, you will also encounter this similar situation, to achieve a function can have a variety of options. For example, on many map-based software, when y
See a code in the 9.3 (fully decoupled) section in the Nineth interface of the look in Java, posted as follows:
Import java.util.*; Class Processor {public String name () {return getclass (). Getsimplename (); Object process (object input) {return input;}}
Class Upcase extends Processor {string process (Object input) {//Covariant return return ((String) input). Toupperca SE (); } }
Class Downcase extends Processor {string process (Object input) {return ((String) input). toLowerCase (); } }
Cla
Web Development Notes www.chhua.com daily practice PHP design mode--strategy mode
The strategy pattern is very important in the design pattern and may be the most important pattern in the modern object-oriented design.It is used to create pluggable, replaceable, reusable components.For a complete and simple description
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.