I have just opened a blog in the blog field because some of my study notes have benefited me a lot, so I decided to use this platform to record my learning experience from today. I like GIS secondary development, and I will not leave it here in the future. I have accumulated a little bit of programming knowledge, and I have recorded some notes to link my knowledge.
I am reading a book recently, you must know. net, the book covers a lot of content, for c #,. net platform has gradually summarized and gained a new understanding of the scattered things learned in the past. Record some basic things here.
Let's talk about polymorphism first:
As mentioned in the book, the key to the inheritance-type polymorphism is the design and implementation of the inheritance system. The book provides a simple Column
Files myFile = new WORDFile ();
MyFile. open ();
MyFile is a parent-class Files variable. It retains the reference pointing to the WORDFile instance of the subclass, and then calls a virtual method Open. The specific call is determined at runtime rather than during compilation. From the perspective of the design pattern, the inheritance polymorphism of the base class embodies a IS-A mode, such as WORDFile IS-A Files is embodied in this inheritance relationship.
Different from the inheritance method of the base class, this polymorphism forms an inheritance system by implementing the method conventions of the interface, which has higher flexibility. From the perspective of the design pattern, the interface implementation polymorphism reflects a CAN-DO relationship. The above file loader can also be implemented in this way
IFileOpen myFile = new WORDFile ();
MyFile. open ();
Multi-state running mechanism:
From the technical implementation point of view, it is the dynamic binding mechanism of. NET that achieves object-oriented polymorphism. Static binding can determine the association during the compilation period, which is generally implemented by method overloading. dynamic binding determines the dynamic Association overwriting method by checking the virtual method table at runtime, it is generally implemented using inheritance and virtual methods.