by a specific class in java.How can we use the simple factory model? Let me give you an example. I think this is much easier to understand than a large theoretical text description! Let's take care of the nouveau riche: PAfter using the simple factory model, the nouveau riche now only needs to sit in the car and say "Driving" to the driver. Let's see how it is implemented:// Abstract Product rolePublic interface Car {Public void drive ();}// Specific product rolePublic class Benz implements Car
Design Pattern-Rule Pattern
Concept:
Policy patterns define a series of algorithms that are encapsulated separately so that they can be replaced with each other. This mode changes the algorithm and does not affect the customers who use the algorithm. Policy actually refers to an algorithm.
Example:
A fresh and simple example can make it easy to understand obscure concepts. Let's take a look at a strategy model about auto prices.
We know that the brand and quality of a car determine its price. Li
Product role: it is generally the parent class or implemented interface inherited by a specific product. It is implemented by interfaces or abstract classes in java.
3. Specific product role: the object created by the factory class is the instance of this role. It is implemented by a specific class in java.How can we use the simple factory model? Let me give you an example. I think this is much easier to understand than a large theoretical text description! Let's take care of the nouveau riche:
The simple factory model is one of the factory models. There are three factory models: the simple factory model, the factory method model, and the abstract factory model, that is, all object creation tasks are handed over to the factory. From the simple factory mode to the abstract factory mode, the abstract level gradually increases.
The factory model consists of three parts: the factory role, the abstract Product role and the specific product role.
The factory role is the core of the factory m
Fu's car is a big brown space BMW, more than 1 million purchases, men driving such a car, very face-recognition, not a successful person, General white-collar companies, where can I start a car like this?
Yan Fukai opened the BMW, and his heart was very proud. Almost every girl he wanted to soak in, after sitting on his car, will reveal a kind of admiration and envy, wishing she could not immediately becom
Condition testThe core of each if statement is an expression with a value of ture or false, which is known as a condition test. Python determines whether to execute the code in the If statement based on the value of the condition test as ture or false. If the value of the condition test is Ture,python, the code immediately following the IF statement is executed, and if it is False,python, the code is ignored.string comparisonstring checking is case-sensitiveCheck for equality"
The function of an array object is to store a series of values using a separate variable name.Create an array and assign it a value:Instance
var mycars = new Array ();
Mycars[0] = "Saab";
MYCARS[1] = "Volvo";
MYCARS[2] = "BMW";
What is an array?an Array object uses a separate variable name to store a series of values.If you have a set of data (for example: car name), there are individual variables as follows:
var car1= "Saab";
va
.111cn.netckindex/topicid=294g0008,setid=0.html"Target=nt_phview> Pentium B50href= "Http://www.111cn.net"Target=nt_phview> Pentium B70class= "Btn-unfold hidden" href= "Http://www.111cn.net" >href= "Http://www.111cn.net"target=nt_phview> BMW href= "Http://www.111cn.net"Target=nt_phview> BMW 3 Series href= "Http://www.111cn.net"Target=nt_phview> imported BMW 5 Seri
In a recent training session with Huawei, the lecturer asked the student a question: what is the difference between the sample and the product?This is an interesting question, it is difficult to give persuasive answers simply from the perspective of research and development, production and marketing. A more general view is that the mass production is the product, the experimental small amount of produce is the sample. Is that so? Let's analyze it.
Once I was asked what the difference between sa
I. Definition and assignment of variablesDECLARE @ variable name typeSET @ variable name = valueegCheck the car table with the name of the BMW two wordsDECLARE @name varchar (20)Set @name = ' BMW 'SELECT * from car where Name like '% ' [email protected]+ '% 'Check the average of all cars in the car table and outputDECLARE @price decimal (10,4)Select @price = AVG (price) from Carprint ' average price for all
1. IndexAdd an index, design the interface, right-click on any column--index/key--tap to add an index2. ViewThe view is the virtual table we've queried.Creating views: Create View name asSQL query statements--grouping, sorting, in, and so on cannot write view usage: SELECT * from view name3.SQL programmingA, defining variables: DECLARE @ variable name data typeB, Variable assignment: SET @ variable name = valueC, output: Print variable or stringFor example: 1, check the car table name contains t
Reflection (3) Reflection application: a plug-in project, plug-in Project
The previous section summarizes the use of reflection. This article combines a complete project to summarize the practical application of reflection.Project Structure
For example:
Define plug-in Interface
In project ConsoleApplication6.IService, two interfaces are defined. Run represents driving, and Trun represents steering. The following code:
1 namespace ConsoleApplication6.IService 2 {3 ///
Plug-in implementation
He
---- Simple factory (also called static factory model): An abstract product abstracts multiple product classes and a specific factory class.
Code:
// Abstract Product role public interface car {public void drive ();} // specific product role public class Benz implements car {public void drive () {system. out. println ("Driving Benz");} public class BMW implements car {public void drive () {system. out. println ("Driving
include Smart fortwo, the wheelbase is only 1867mm.
Small car:
Generally, a car with a wheelbase between 2550mm-is called a small car, such as Honda Fit, Toyota Vichi, and Ford Fiesta.
Compact car:
Generally, a model with a axis distance between 2700mm-is called a compact car. This type of car is a mainstream model of a household car, such as Volkswagen sagitarta, Toyota Karla, Ford forks, and Honda Civic.
Medium-sized vehicles:
Generally, a model with a wheelbase between 2850mm-is called a med
Mercedes-Benz-Excellent craftsmanship
BMW-Driving Force
Volvo-Security
Domino (pizza)-Home Delivery
Pepsi-young people
There are different types of trademark names. They can be used-related (for example, anti-dental caries); they can be
Services (such as home delivery), objects (such as young people), or
It can be related to sales (a trademark that is preferred by recruiters ).
Although we have repeatedly stressed that trademarks will take root in us
wedding, each present guest presented a gift bag, which is the same as Tiffany's crystal candy box, which should be customized and engraved with WL, the capital letter of the bride and groom. ========================================================== ==== Car Model reviews] the strongest wedding car in history is worth RMB 28 million (reprinted) This wedding can be said to be the most luxurious and luxurious wedding that xiaobian has ever seen. 12 black B
The simple factory mode is also called the static factory method mode. After renaming, we can see that this mode must be very simple. Its purpose is to define an interface for creating objects.
2. Applicable scenariosIf a customer wants a BMW, the general practice is to create a BMW and use it. Then there was an industrial revolution. You do not need to create a BMW
diagram of the driver driving the Mercedes Benz is as follows:The implementation code is as follows:// Driver's realization class Public class Driver { publicvoid Drive (Benz Benz) { benz.run ();} }// Mercedes-Benz car implementation class Public class Benz { publicvoid run () { System.out.println ("Mercedes Benz ...") ); }}// scene Invocation class Public class Scene { publicstaticvoid main (string[] args) { new Driver (); New Benz (); D
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.