Java Tour (8) Reuse (Continued)

xiaoxiao2021-03-06  69

You have to understand that procedures are a gradual process like people's learning. No matter how much analysis, don't actually do the project, or you can't get the answer. If you can abandon the development method of the development of the glass skyscraper, use similar biological evolution, let that project gradually "growth" development method, then you will get a bigger success - and more Timely feedback.

Transmitting the derived class to the base class is to be sent along the inheritance, and thus is called "Upcasting". Upload is always safe, because you are converting a more specific type to a more general type. That is to say, the derived class is a supercharge (SuperSet).

Synthesis or inheritance, then discuss: In the programming of the object, the most common programming and use of the code also simply encapsulates the data and methods to the class, and then use the object of that class. You can also create new classes on the basis of existing classes. Inheritance is less common. When judging that the use of synthesis or inherits, there is a simple way, just ask if you will transfer the new class to the base class. If you have to upload, then inherit is a must, if you don't need to upload, then you should see if you should use it.

Final three uses: Data (DATA), Method (Method) and Class.

Although the object-oriented programming will repeatedly emphasize inheritance, when you start designing, usually should still consider synthesis, only inheritance is used when necessary. Synthesis will be more flexible.

// Reuse this chapter finally finished reading, now there is a feeling of "C Programming Thoughts" that year: Simple problem complicates.

转载请注明原文地址:https://www.9cbs.com/read-90557.html

New Post(0)