Java internal class (InnerClass) ---- non-static internal class, static internal class, local internal class, anonymous internal classMany people are not familiar with the java underwear Class
Iterator mode: provides a method to access each element in an aggregate object sequentially without exposing its internal representation.
The iterator mode provides a way to access elements in an aggregate object in sequence without having to know how they are identified internally. In addition, the iterator mode transfers the responsibility for migrating between elements to the iterator, instead of aggregating objects, so that aggregation is more focused on data sets.
Case study: My friends
This model takes a long time and is hard to understand at first.
Definition: dynamically add some additional responsibilities to an object, just like painting on the wall. Using the Decorator mode is more flexible than using the subclass method to Expand functions.Original design intention: inheritance can usually be used to expand functions. If there are many types of functions to be extended, many sub-classes will be generated to increase the complexity of the system. At the same time, when us
1. Model Introduction
Definition of a pattern
Make sure that there is only one instance of a class, and instantiate it and provide this instance to the entire system.
Usage Scenarios for patterns
Make sure that a class has a scenario with only one object, such as too many resources to consume for creating an object, such as access to resources such as IO and
programming. I have summarized the scenarios that I know are applicable to the singleton mode:
· Objects that need to be frequently instantiated and then destroyed.
· Objects that are frequently used when creating objects that are time-consuming or resource-consuming.
· Stateful tool objects.
· Objects that frequently access databases or files.
· And other scenarios that require only one object.
Considerations for Singleton mode:
· You can only obtain the singleton object using the method provi
Random ();
public static Flower Newflower () {
switch (rand.nextint (2)) {
default: Case
0: return
new Gladiolus ();
Case 1: Return
new Chrysanthemum ();}}
The public class Test {/
* * First obtains a specific visitor role traversal object structure on the client to call the Accept method on each element, passing the specific visitor role in this completes the entire process.
static void M
Appearance mode: Also known as façade mode: Facade façade provides a consistent interface for a set of interfaces of a subsystem, making this subsystem easy to use (by introducing a new appearance role to reduce the complexity of the original system, while reducing the coupling between the customer class and the subsystem).
Image source: Design pattern: The basis of reusable object-oriented software.
Re
Java Tour (ix)--object class, Equals,tostring,getclass, inner class access rule, static inner class, Inner class principle, anonymous inner class
Every day by some trivial harassment, learning to continue
I. Object
转载请注明出处:http://blog.csdn.net/l1028386804/article/details/45568655
I. Overview
Provides a consistent interface for a set of interfaces in a subsystem, and the façade pattern defines a high-level interface that makes the subsystem easier to use. Second, applicability
1. When you want to provide a simple interface for a complex subsystem. Subsystems tend to become more complex as they evolve. Most patterns will produce more and smaller classes when use
Name:Composite
Structure:
Intent:
Combine objects into a tree structure to represent the "part-whole" hierarchy. C o m p o s I t e makes the use of a single object and a composite object consistent.
Applicability:
The part of the object-the overall hierarchy.
You want to ignore the differences between a composite object and a single object. You will use all objects in the composite structure in a unified manner.
Instance:
Employee.
Template method is better understood, is to avoid code redundancy, implementation of code to take the function. For example, the most common tea and coffee, two have a lot in common, all need to boil water, all need to pour into the cup, then these repeated methods can be drawn out, placed in the parent class, as for the different methods, write an abstract class, so that different subclasses to rewrite the
of an algorithm. A the template method not only invokes primitive operations, it also invokes operations defined in AbstractClass or other objects. at -2. Concreteclass -Implements primitive operations to complete the steps associated with a particular subclass in the algorithm.Test class: 1 public class Test { 2 public static void main (string[] args) { 4 Temp Late temp = new Templateconcr
Interpreter mode, that is, Interpreter mode.The interpreter mode is a behavior mode. The Gof defines a language, a syntax expression, and an interpreter. This interpreter uses this expression to describe the language.Explain sentences in a language.What needs to be solved in the interpreter mode is that if a specific type of problem occurs frequently enough, it may be worth expressing each instance of the problem as a sentence in a simple language]. In this way, an interpreter can be built to so
Defined:defines the framework for an algorithm in an operation, and delays some steps into subclasses. So that subclasses can redefine some specific steps of the algorithm without altering the structure of an algorithm.
Sounds like a good high-end look, I understand:
1. The parent class declares several abstract methods (basic methods) and several specific methods (template methods)
2. Abstract methods are steps of an algorithm (process) that are i
First write a singleton, lazy mode: Public class Singledemo { privatestaticnull; Private Singledemo () {} Public Static Singledemo getinstance () { ifnull) { new Singledemo (); } return s; }}Write a test class: Public class ThreadDemo3 { publicstaticvoid main (string[] args) { = Singledemo.getinsta
policy algorithms are independent of each other in terms of implementation, and there is no dependency between them.
So we can describe this series of policy algorithms as follows: Policy algorithms are different implementations of the same behavior.
Uniqueness of runtime policies
During running, the policy mode can only use one specific policy to implement objects at a time. Although you can dynamically switch between different policy implementations, you can only use one.
Public Behavi
Notes | design
The principle of the Richter substitution----LSP
Concept: If a software entity uses a parent class, it must apply to it, and it cannot perceive the difference between the parent class and the subclass.
The principle of the Richter substitution is the cornerstone of succession reuse. Only when the derived class can replace 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.