Unity Development Programming principles (seven major object-oriented design principles) __ design mode

Source: Internet
Author: User
Seven main object-oriented design principles

Opening and closing principles : In the face of demand, changes to the program is done by adding new code , rather than changing the original title

dependency Reversal Principle : High-level modules should not rely on the underlying modules, two should be dependent on the abstract, the abstract should not rely on the details, the details should depend on the abstraction. So to programming for the interface , do not program for implementation.

The richter substitution principle : Because subclass objects can be used where the base class object is used, the base class type is used to define the object in the program, and then the subclass type is determined at run time, and the subclass object is substituted for the parent class object

Single Responsibility Principle : An object should contain only a single responsibility, and that responsibility is encapsulated completely in a class, in the case of a class, there should be only one reason for it to change

interface Isolation Principle: interface Isolation principle refers to the use of a number of specialized interfaces, rather than the use of a single total interface. each interface should assume a relatively independent role , not too much, do not do what should not be done, the matter should be done

Synthetic Reuse Principle : the principle of composite reuse is to use some existing objects in a new object to become part of the new object by means of association relations (including combinatorial relationships and aggregation relationships). The new object uses the method of delegating to invoke an existing object to reuse its existing function. In short: try to use a combination/aggregation relationship, using less inheritance

Dimitri Rule : A software entity should interact with other entities as little as possible . In the structure design of a class, each class should minimize the access rights of its member variables and member functions

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.