Overview Object-Oriented Design (Java) (Today, everyone is talking, object-oriented OOP, but truly understanding the programmer for object-oriented meaning, there is very little, what is object, how to object-oriented) one. Object-oriented: 1. What is object: In object-oriented programming, we will summarize the 5 basic features of the object in SMALLTalk in the SMALLTalk in the object-oriented programming. : All things are objects. The program is a collection of a lot of objects, they pass messages, know what to do between the objects. Each object is allocated with its own storage, which can accommodate other objects. Each object has a type. All objects of the same class can receive the same message. ----- The ultimate goal of all programming languages is to provide an abstract method ---- 2. Object interface: We send a request to an object to be defined by its interface, and the type of object determines its interface form. 3. The only concern in OOP: What is the interface, just like a car engine, we don't have to know what it is, as long as it can work. All programs are composed of certain attributes (data) and behavior (methods), different object access through function calls, all communication between the objects are called by way of ways, vale to packaging data objects, large extent Improve the reuse rate. 4. 3 main features of the object: Behavior- Description This object can do. State - Reflection of the object when the object is applied. Identity - distinguished with other similar behavior objects, each object has unique Indentity, and these are interactive. 5. The most important idea in object-oriented is class, class is a template is a blueprint, constructed from the class, which creates an instance of a class. (The class is better than a building materials market, including many children - a wide variety of decorative materials, and we renovate your own house to choose the materials we need, (in order to build our own procedure, we must choose our need Class) This metaphor can be an explanation class. 6. Relationship between class: Dependencies: One method in the USE-A c class operates an object in another class. Polymer relationship: HAS-A a Objects in the class contain objects of Class B. Inheritance: IS-A a inherits Class B, at this time, the Class A is not only a B class, but also adds its own method. So we create the object we need. Each class defined in Java must inherit another class, use keyword extends, if a class is unrealistic using keyword Extends in the definition, this class is implicitly inherited Object class. Object class is also a superclass, Or base class. We are from root superclass inheritance.
8. Interfaces specify which requests can be issued to specific objects. 9. Inheritance = Reuse interface: After creating a data type, when the newly established data type is required to achieve the same function, it is a very meaningful thing. At this time, it is cloned, and then improves its own purpose according to the situation. It is inherited.
10. Package: Just combine data and behavior together in a package and the implementation of the object user hides the data. Java uses 3 keywords to set the boundary, thus hiding data. The definition of public (a common) can use .private means that anyone can use any other use of anyone who can use anyone else, anyone who can access anyone else, in addition to your own, type creator, and that type. Friendly means accessible in package (package). (The above process can also be called the scheme hidden) 11. Quote: String S = "Happy" string s = new string ("happy") String s = new string ("Happy") is used to connect to a new object connection using new object. This sentence has established a reference, and the connection references and initializes the object assignment string "happy" .12. Object creation and existence time: Data storage Location 1: Register - fast, number, in the CPU, our pair of registers There is no control. 2: Stack: In the long-term memory, the stack pointer is moved down to establish a new memory and release the memory upload. 3: Heap: Common memory pools, save objects, have great flexibility, Java's data is stored here, but it is expected to be at time and efficiency. Java's object establishment is determined when the program is running. And C is established when designing. Object Survival Time (Lifetime) Java proposed garbage collector can find a Non-reused object, using Grabage Collector garbage collector. Clear objects and release memory. To this end, we have to pay a certain operating period overhead. 13. We will have such an impression, a program is just a collection of objects, and their methods use other objects as their own variables. 14. Main type: Java's main types: Boolean, char, byte, SHORT, INT, Long, Float, Double, Void. These main types are not changed with the structure of the machine, providing Java good portability .15. Field method: field is also called data member, member function Also called the method, all of Java is to define classes, produce accumulated objects and send messages .16. A program is just a collection of objects, and their methods use other objects as their own variables, and send messages to those Objects. 17.Netice: In order to make the name do not repeat, the author can define your own library, generally use your own domain name, such as: com.:leeak.utility.foidles18.static keyword: Even if you don't create an object, It also needs a way to call the way. You can use static19.java.lang default Automatic importance into 20.Oop in each Java program to make the properties and methods package, the object has the hidden nature of information, for details The hidden, the object only needs to know this, and not know how to do the details, the class method should be cautious to control the Java data access, you can use the get to read the method to modify the method.
21: Pakage: Each class and interface in the Java API belong to a specific package, the package actually listed on the class and interface to organize the structure of the structure, which provides a software multiplexing mechanism. 22. Creating a reused class step : 1. Define a PUBLIC class 2. Select a package name and add the PAKAGE statement to the source code of the canable class. 3. Compile this class. 4. Import the accessible class into other programs. 23. Java proposes only 2 statements outside of class definitions, Pakage and Import.24. Software reuse, software reuse is the existing purple, defined well test Document Clear portable easy-to-offer software components develop new software. The above is an overview of some basic terms of Java object-oriented, some of which can be extended, and some friends who have seen Think in Java will have such It feels. This article explains the object-oriented basic concept to beginners. It is a matter of the basic knowledge that is already a Java programmer.