"Thinking in Java" learning notes (1)
---- Object Admissions
Author: Lonely Firefly
SMALLTALK's five basic special specials are also the most pure side of object-oriented programming:
1. All things are all objects.
2. The program is a pile of objects, and the other objects are requested to work with each other.
3. Each object has a memory consisting of other objects.
4. Every object has its model.
5. All subjects accepted by the same type are the same.
Program developers are divided into: developing new data types, so-called Class Creators, and so-called client programmers (Client Programmers) developed using others in the application. Class creator sets two reasons for "access control control mechanism":
1. Let the client's deskman can't touch things they should not touch - these parts should only be used inside the Data Type, which makes the user can easily see which things are important to them, which can be ignored.
2. Let the library designer can change the Class internal operation mode without worrying about impact client programs.
Inheriting is important in object-oriented programming, but excessive emphasis often makes novices to "use inheritance everywhere", resulting in misuse, resulting in too complex design. Create a new Class while should consider the combination, because it is simply flexible. After some experience, it is necessary to use the timing of the inheritance.
Later Binding: When you send a message to the object, "the program code that should be evoke" will be decided until the execution period. However, the compiler is still a responsibility to determine the existence of a function, and type the quotes and return values (not available to this guarantor, the so-called "Weakly Typed" language), but the compiler is still unable to know Which program code will be executed.
The binding action of all MEMBER FUNCTIONS in C defaults to "non-dynamic", and it must be clearly indicated whether a function wants a function to have the elasticity of the later binding; and the province of Java is dynamically binding.
Up transformation: Devine the DeriveD Class as the process of its Base Class.
Since the management method of the storage space is dynamic due to the execution period, the time consumed from the HEAP allocation space is much larger than the time required to generate the storage space from the STACK. In program languages that "Allow Object Birth in Stack", the compiler will determine whether the object will survive and can be automatically destroyed. But if an object is generated in Heap, the compiler will not know any life.
The iterator allows us to visit the entire sequence without having to worry about the underlying structure is ArrayList or LinkedList or Stack or other.
If the system characteristics of the "single inheritance system" and "Operation of the object fully" are lacking, the implementation of the garbage collector is very difficult.
Although object-oriented language often manifests an abnormality, the abnormal processing mechanism is not object-oriented.
A fragment that can be performed can be a so-called thread. The memory used by any object can be locked by keyword synchronized, so that only one thread can be used in the same time.
In Java's design concept, the implementation of Applet is limited to the protected sandbox (Sandbox). In the sand box, Applet cannot write data to disk, and cannot access memory content outside the sand box. "Public Key Encryption" allows us to verify that Applet is really since he claims. Java provides a complete architecture for digital signatures, so you can still let the applets in the cassette cage when necessary.
Fish and bear's paw are not partial, and the development speed is at the expense of execution.
The entire development process can be divided into five phases:
Stage 0: Planning
Some milestones are set for the entire route to help people gather the focus of work and arouse the efforts of work between one milestone, and not only assume the only goal of "Completion Project". Stage 1: What is established?
Use case.
Stage 2: How to build
The five major phases of the object design:
1. Exploition of the object
2. Combination of objects
3. Construction of the system
4. Extension of the system
5. Repeat of objects
Stage 3: Creating a core
The resulting framework is the framework of the foundation.
Stage 4: Iteration of Use Cases
The function group is added in the so-called "iteration" process.
Stage 5: Evolution
Not only should you operate according to customer needs and use cases, but also make the internal structure of the program code, there is no difficult grammar, too large object, and there is no ugly code.
The power of OOP is that it can regard the elements in the topic domain as an object, regarding the activities in the topical domain as the message passed between the objects, so it is easy to understand the content of the program code.