C # object-oriented Review & gt; 2015.12.23,

Source: Internet
Author: User

C # object-oriented review> 2015.12.23,

First, we need to know the three features of object-oriented

  • Encapsulation

In program development, it can be understood as method encapsulation of Common Code, class encapsulation of common methods.

The benefits of doing so are:

First, reduce code redundancy and make the code more organized.

Second, you do not need to know how the method is implemented at the underlying layer. You only need to know how to call the method.

  • Inheritance

Inheritance is used to solve code redundancy between classes. Generic attributes and functions are written to the parent class. Child classes inherit from the parent class and inherit from all attributes and functions of the parent class, inheritance supports inheritance and interface inheritance.

  • Polymorphism

Consider different subclass objects as parent classes to avoid the differences between all subclasses and implement common code to adapt to constant changes.

Next, we need to understand the five features of object-oriented

  • Single Responsibility Principle: an object should contain only one single responsibility and fully encapsulate this responsibility in a class. If a class is encapsulated with excessive responsibilities, these responsibilities interfere with each other during concurrent execution.
  • Open and closed principle: the application is extended and the code is modified and closed during development.
  • Dependency inversion principle: High-level modules should not directly depend on lower-level modules. The correct method should be dependency abstraction.
  • Rys replacement principle: Child classes can be replaced with parent classes.
  • Interface isolation principle: the client should not rely on interfaces that it does not need. Otherwise, code will be bloated and redundant.

Related Article

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.