Chapter I. OO Wisdom

Source: Internet
Author: User

Today, we formally begin to read Wang Tao's "You Must know." NET (second edition), just began to read the preface, felt that the writing is quite wonderful, was attracted. For a while, I found that the characteristics of this book may be exemplified by examples, vivid images, and more expected appearance. Although the concept of the above-mentioned things, too basic, but the attitude of the beginning and end, to have a good start to have a good ending, otherwise always feel something fell like.

Notes

  

1, where the method of ShowType is virtual function, the way of implementing virtual function in subclass, it becomes dynamic binding of method, it is another characteristic of realizing object-oriented: The basic mechanism of polymorphism.

2, Eagle realizes the interface iflyable, thus guarantees the separation of the object and the behavior, and protects the integrity of the system.

3, the essence of inheritance: the creation of the field, chicken create first find bird, and then find animal, and so on, recursive end, finally find the object, and then allocate space, the highest level class ranked at the front. The method table is created when the class is first loaded into the AppDomain, and when the method table is created, it simply attaches its attached member Typehandle to the address of the method list on the loader heap. When chicken is created, a copy of all the virtual methods in the bird is first copied, and then compared to the method list of the chicken itself, if the subclass is already duplicated, the child class overrides the virtual method of the parent class.

4, the object-oriented basic principles: multi-aggregation, less inheritance; low coupling, high cohesion.

5, Adapter Mode: Class adapter, is to inherit each class under the appropriate adapter, adapter unified implementation of the interface, so as to achieve the effect of the adapter, the object is to establish a unified adapter class, implement the interface, in the adapter class, in an aggregate way for each class's functionality implementation.

6, the so-called package, that is, you can only take cards in the ATM machine to take money, you take bricks do not go in, take the bus card is not recognized. haha ~ ~ ~

7. Encapsulation tells us that the fields in the class are best set to private and can interact with the outside world through attributes. This has two advantages: one is to improve the data security, and the second is

8, after the anti-compilation property, found that its compiled result is the Get_ property name, set_ property name, which indicates that the property compilation process, is to turn it into two corresponding simple method.

9, summarized as follows:

  

  

10, polymorphism is divided into: The base class inherits Polymorphic (IS-A) and the interface realizes the polymorphism (can-do).

  

11, good design is usually oriented towards abstraction, interface is one of the perfect means to realize this idea, the high level relies on abstraction, does not depend on concrete. The interface isolation principle emphasizes that an interface should be declared as a small interface with a single function, rather than as a thick interface with multiple functions.

All right, let's go today and continue tomorrow.

  

Chapter I. OO Wisdom

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.