Good software design habits

Source: Internet
Author: User

The software design process involves several types of source code-related roles: 1. User; 2. Modifier

1. Closed principle. Things that users do not need to know are closed. One can reduce irrelevant information reading, and the other can reduce misuse, increase code coupling, and increase the difficulty of code modification in the future.

2. abstract interface principles. The user references abstract interfaces, which reduces the difficulty of modifying the code.

<P $1 $2 $3 $4 $5 $6>

There are usually not many things in principle, but the specific measures are quite extensive.

How to implement the principle of closures?

First, you need to know what is closed and how close it is. Many languages can be closed in multiple layers, for example: 1. within the project; 2. file; 3. classes can be public, inherited, and private. 4. class Members are public, inherited, and private. The principle of how to implement the closure is that, within a certain range, you do not want to or do not want to make public, or you cannot decide whether or not to make public, all remain closed.

How to Implement the abstract interface principle?

We have discussed the concept of closures. The so-called interface is actually the content published within a certain range. As long as it is made public, the user may use it. If you want to modify it, you may have to change the interface. Therefore, to implement the abstract interface principle, we must first implement the closed principle. Only the closed interfaces are closed, and only enough interfaces are provided to users (such as through interfaces and abstract classes). This implements the abstract interface principle.

<P $1 $2 $3 $4 $5 $6>

To be continued ~

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.