Arcgis Engine-interface programming ideas

Source: Internet
Author: User
Tags map class types of functions
Arcgis Engine-interface programming ideas(12:14:06)
Tags: Miscellaneous Category: ArcGISEngine

-- This article is for reposted favorites and is for your reference only.

   The most important thing to learn about AO is to understand the concept of "interface. What is an interface? What are the specific functions? In many advanced computer languages, you can see the term "interface". However, basically every book has an "unknown explanation" for important texts such as "Why is an interface used ", so that beginners often have no essentials.
   To understand the interface, you must first familiarize yourself with the history of the development of the programming language and understand the past and present of the development of the programming language, so that you can understand why so many computer languages look like this, why is there a different form between them.
After the emergence of computers, mathematicians and computer scientistsDevelopmentA variety of advanced computer languages, from Small-talk, Pascal, Basic, C, C ++,JavaThe pace of development of various languages on the. NET platform can be seen as a historical development of computer languages from process-oriented objects. Many textbooks for object-oriented languages will tell readers about this history and declare OO (Oriented-Object)Programming. When changing from process-oriented to object-oriented, the terms that need attention have changed from "process" and "function" to "class" and "object.
 What is an interface? Why use interfaces? It is very difficult for beginners who have no programming experience to understand them.
 Before understanding the essence of these issues, let us first understand a concept-"granularity ". The so-called granularity is actually a combination of code units used in a program. For example, there are many ways to build a house in gravel-brick-house module: if you are not in too much trouble, you can use gravel to pile up a little or burn gravel into bricks, even directly from the construction plant to buy a house door and window wall to build for installation. These three different methods represent three different combination scales. Gravel is the smallest unit. It can be used to build a small house, but it is powerless to build a large building. This is because there are too many gravel and it is not easy to manage. Bricks aggregate a layer than gravel, it can be used to build a large house, and the housing template is the highest standard. It can be used to quickly build a large-scale house. The differences and connections between these three scales are very similar to the programming concepts of programmers.
 In Pascal, the basic units of this process-oriented language are processes and functions, which are the smallest components in the program. Processes and functions can achieve the most basic code reuse. When some fixed functions are written as processes and functions, you can call them in the program without having to write long duplicate code. This is obvious. In some small programs, the use of procedures and functions is appropriate, but in large and medium-sized programs, their drawbacks show that the granularity of processes and functions is too low. If a system contains functions and processes, the programmer will have to spend a lot of time searching for and maintaining them, the difficulty of managing 10000 functions and processes without any relationships or complex relationships is obvious, just like an enterprise with 10000 employees. If there is no department or position, everyone is the same.
  The emergence of object-oriented language is actually for a reason-improving the programming granularity. The basic unit of object-oriented language is Class. It encapsulates data members (attributes) and member functions (methods) and increases the minimum component level, what programmers need to perform directly is not a process or function, but a class at a higher level. This is equivalent to dividing 10000 employees into multiple departments, so that different departments are responsible for different matters, so that the company can finally be on the right track.
 This is a logical abstraction.
 When a CLASS is created, it does not solve all the problems in programming, and the new problems follow. Assuming there are many employees in a department, you can do a lot of work, how can we achieve better management between departments? For example, there is a class that provides many methods and attributes. These methods and attributes can be divided into a group to serve different functions, but the class does not manage them, she is just a container for attributes and methods. In AO, Map objects have many types of functions, such as Layer Management, element management, selection set management, and display.MapAnd so on. Each function group has many methods and attributes. These attributes and methods are disorganized and stacked in a class without any difference, when programmers need to find a method, they have to traverse them. This is inconvenient.
 InterFace solves this problem by classifying the Internal Attributes and methods of the class. For example, you can create several interfaces in the MAP class, define methods and attributes of different functional groups in these interfaces, and MAP implements these interfaces so that you can define them using interfaces, for example:

        Dim pGraphicsContainer As IGraphicsContainer

         PGraphicsContainer = pActiveView. FocusMap

   The attributes and methods that can be used by the pGraphicsContainer object can only be defined by the IGraphicsContainer interface, but cannot be used.OthersHow do I use the attributes and methods defined by other interfaces? This is the so-called QI (Query InterFace) function, that is, to Query the attributes and methods defined by another InterFace of an object, such:

        Dim pActiveView as IActiveView

        PActiveView = pGraphicsContainer
 Through the above operation, pActiveView can now use the IActiveView interface in the MAP class to define the attributes and methods, which achieves conversion between different interfaces of a class.
 An interface is a protocol used to define a program. The class that implements the interface must be strictly consistent with the interface definition. With this protocol, the system can put aside the restrictions of programming languages. Interfaces can be inherited from multiple parent interfaces, while classes can implement multiple interfaces. interfaces can contain methods, attributes, events, and indexers, she does not provide the Implementation of the members she defines, but only specifies the class or the members that the interface must provide. You can use interfaces to replace classes, except for using classes to generate an object.
 An interface can be considered as a special class form. Besides not instantiating an object, it can implement any tasks that can be completed by the class, for example, declaring an object as an interface type, interfaces can also be inherited. The interface inheritance mechanism is very useful. For example, a subclass object can be considered as a parent class object, and the interface also has this feature, in many cases, programmers can define an object of the word interface type as an object of the parent interface type to implement general operations, such:

       Public Sub CreateGeometry (Byval pPolygon As ipolympus gon)

       Public Sub CreateGeometry (Byval pPolygon As IGometry)
   One of the parameters of the above two processes is to use the ipolympus Gon object, and the other is to use the IGometry object. The latter can be used more broadly and securely. If it is accidentally transmitted to an IPoint object, it is also valid in the second method, because the IGometry object can be any geometric object, which is wrong in the first process.
   One class can implement multiple interfaces, and one interface can also be implemented by multiple classes. Using the image comparison method, you can regard the class as a person, and the interface as an identity. A person may have multiple identities (one class can have multiple interfaces) and may be a soldier (the military interface defines the attributes and actions of a soldier ), writer (writer interface defines writer's attributes and behaviors). different identities give him different abilities and attributes.
 One identity (Interface) can also be used by multiple users (one interface can be implemented by multiple classes ). For example, a military identity can be assigned to many people, but these people can achieve this identity with different capabilities and attributes. They may be Air Force officers or naval troops. Identity only defines what a person is, but does not tell others to do so under this identity. How to do this is the case of this person (the interface only defines relevant methods and attributes without implementing them ).
 This is the specific method.
 The history of computer language development is actually a history of constantly searching for better component granularity and improving code reuse. In the past, programmers used procedures and functions, and later used classes, interfaces, packages, namespaces, and so on for a single purpose, that is to let programmers find a balance between the specific and abstract components that can be operated. This is not an easy task-too specific, such as procedures and functions, without the framework; it is too abstract, such as a class, so you cannot go into detail.
 This is the philosophy of programming.

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.