1. Abstract process
Alan Kay summarizes the object-oriented programming language:
- All things are objects.
- A program is a collection of objects that they send messages to tell each other what they want to do.
- Each object has its own storage that is composed of other objects.
- Each object has its type.
- All objects of a particular type can accept the same information.
Booch has a more concise description of the object: the object has state, behavior, and identity. This means that each object can have internal data (they give the state of the object) and methods (which produce the behavior), and each object can be distinguished from other objects, meaning that each object has a unique address in memory.
2. Each object has an interface
Creating abstract data types (classes) is one of the basic concepts of object-oriented programming.
Class describes a collection of objects that have the same attributes (data elements) and behaviors (functions), so a class is actually a data type.
One of the challenges of object-oriented programming is to establish a one by one mapping between the elements of the problem space and the objects in the solution space.
3. Specific implementations that are hidden
One reason for the presence of access control is that the client programmer is unable to reach the part that they should not touch, and the second reason is to allow the library designer to change how the class works inside.
Java uses 3 keywords to set boundaries within a class: Public,private,protected.
Public: Indicates that the element immediately followed is available to anyone.
Private: Represents an element that cannot be accessed by anyone other than the class creator and the inner method of the class.
Protected: Similar to private, the difference is that inherited classes can be accessed.
Nothing else, called Package access, a class can access other class members in the same package.
4. Specific implementations of multiplexing
Using an existing class to synthesize a new class is called a combination. If the composition is dynamic, it is called an aggregation.
When creating a new class, consider the combination first, because he is more flexible.
5. Single-Root inheritance structure
A single inheritance structure guarantees that all objects have some functionality.
A single inheritance structure makes it easy to implement the garbage collector.
6. Containers
Different containers provide different types of interfaces and external behavior.
Different types of containers have different efficiencies for some operations.
7. Parameterized type
Before the advent of Java SE5, objects stored in containers had only common types in Java: Object
One of the major changes in Java SE5 is the addition of parametric types: paradigm. Arraylist<?>=new arraylist<?> ();
The first chapter of Java programming thought