-------------------------------------------------- ------------------------------- | Design Pattern | 1.Template: Define each interface function via Abstract Class, where The function is inherited or implemented by subclass derived class, which is that Function can be reused by derived classes, and the Function is configured for configuring. As in instance below. Public Abstract Class Benchmark {/ ** * The following is what we want to complete * / public abstract void benchmark ();
/ ** * Repeat Benchmark number * / public final long repeat (int count) {if (count <= 0) Return 0; else {long starttime = system.currenttimemillis ();
For (int i = 0; i Long stoptime = system.currenttimemillis (); returnTime - starttime;}}} | Lenovo | | Question | | Thinking | | Others | OO principle is to subdivide for anything, and package it, and IT industry means Accelerate Enterprise production, make the process of any enterprise more variable, so you need a fast strain, rapid deployment, and the Template mode sets a variety of shared production methods. And by interface programming, the things will be subdivided. The need to be deeply understood is package and polymorphism and delegate. The abstract benchmark method is defined above, so that the skeleton REPEAT can be configurable and reuse in the later derivatives. 2.Factory | Lenovo | | Problem | | Thinking | | Others | Using Dynamic Load Class. The OO principle is to continuously subdivision of various things, and expandable, easy to deploy, such a benefit that the company can quickly strain, and everyone's life is also the same. The Factory mode makes users only telling Factory what I need, and don't need to manage how this object is created. This effectively reaches the polymorphism and the package of packages. In addition, it is necessary to make things more variable, so that the dynamic loading class needs to be used to complete the functionality of the response. You can fill in the object you want to generate in a property, and Factory returns to your parent class according to the object you want to create, because the interface is programmed, so the implementation of the object can be different, so it is used up. Polymorphism. (to be continued) -------------------------------------------------- ------------------------------- -------------------------------------------------- ------------------------------- | Template | 1. | Lenovo | | Problem | | Thinking | | Other | 2. | Lenovo | | Problem | Thinking | | Others | 3. | Lenovo | | Problem | | Thinking | | Other | 4. | Lenovo | | Problem | | Thinking | | Other | 5. | Lenovo | | Problem | | Reflection | | Others | 6. | 联 | | | 问题 问题 | | | | 问题 | | | | | 其他 | | | | | | | Problem | | Thinking | | Others | 10. | Lenovo | | Problem | | Thinking | | Others |