From 0 self-study c#04--characteristics and design principles

Source: Internet
Author: User
1. Three major features

Encapsulation: hides the internal implementation.
Inheritance: Reusing existing code.
Polymorphic: Overrides object behavior.

2. Design principles

    • Single-duty principle Responsibility Principle (SRP)

A class has only one cause that causes it to change.

    • Opening and closing principle Open-close Principle (OCP):

The class module should be extensible, but not modifiable. (for extended development, closed for modification)

    • Richter Replacement principle Liskov Substitution Principle (LSP):

A subclass can replace its base class anywhere.

    • Interface Isolation principle Interface segregation Principle (ISP):

Try to use a single, functional interface without using a complex, comprehensive interface.

    • Dependency inversion principle dependence inversion Principle (DIP):

High-level modules should not be dependent on lower-layer modules, both of which should be dependent on abstraction. Abstractions should not be dependent on implementation details, and implementation details should be dependent on abstraction.

    • Dimitri principle/least-knowledge principle law of Demeter or Least knowledge Principle (LOD ORLKP):

Requires as much encapsulation as possible to be as independent as possible, using a low-level access modifier.

    • Combination/Aggregation multiplexing principle composition/aggregation reuse Principle (CARP):

If you are only trying to achieve the purpose of code reuse, use combinations and aggregations instead of inheritance.

The above is from 0 self-study c#04--characteristics and design principles of content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!

  • 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.