Object-Oriented Programming and interface-Oriented Programming

Source: Internet
Author: User

1. Definition:

Class(Class) isObject-orientedComputerProgramming LanguageIs to createObjectIs used to describeAttributeAndMethod. (Source wiki)
InterfaceIncludeClassOrStructureYou can define a set of functions.The interface can contain methods, properties, events, indexers, or any combination of the four member types. (Source: msdn)

2. Comparison between classes and interfaces: (abstract classes are not considered)

A. The interface supports multiple inheritance, and the class can only have one base class.

B. The interface only has methods, attributes, events, and indexers, while the class has more members, such as fields and constructors.

C. Only the definition of the member in the interface is not implemented, and the member in the class contains the implementation.

D. The members in the interface are visible, and the Members in the class can be hidden from other classes.

E. The interface can only define instance members,Static members cannot be defined, and the class can contain these two types of members.

3. Understanding of the two programming ideas:

In a system, there are different things to consider. One is to consider objects that follow interface rules, and the other is to consider instances of specific classes.

The interface is more flexible, and the implementation function is also relatively simple. The specific class can implement the function and provide some additional information.

For example, there are three PC output signal modes: VGA, DVI, and HDMI (and many other modes ). The company has a PC and notebook. The Philips display configured in the PC supports VGA and DVI display interfaces, and The Notebook supports DVI Display Interfaces. To improve work efficiency, the PC display and output are connected to the Philips display using vga, And the DVI output from the notebook is also connected to the Philips display. Then, the PC and notebook are opened and the display is set to the extended desktop of the notebook. This is quite comfortable. When using a notebook, you can use a PC Monitor (switch the display signal to DVI). If you want to use a PC, directly switch the signal interface of the monitor to VGA.

Now, you have a laptop and a PC host. Which kind of monitor is better.

A. if you use a Philips Monitor of this type, you will be very happy. This is an example of a specific type.

B. if you have a monitor with VGA and DVI interfaces, No matter what brand, model, or other information (this is a specific analogy interface to provide more information), you will be very happy, this is the object to consider following the interface rules.

C. If you have purchased a single-interface display, it seems that you will not find a single-interface display now.

 

 


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.