Ideal software design standards

Source: Internet
Author: User
A friend mentioned that my blog is empty a few days ago. Indeed, there are some days in the garden. It's time to put something in it. Or Dudu. I have been idle for the past few days. I have recorded my reading notes and my own experiences.
McConnell said that if the design can achieve the following goals, it would be a very good design.
I: Minimum complexity
To put it simply, it is easy to understand. McConnell also pointed out that "smart" design should be avoided. In addition, when designing somewhere, we should be able to safely ignore other parts. Qualified .
II: Easy to maintain
This is mainly for maintenance. Program But we did. Code Most of the time, do it yourself. If you can see the function name or code to understand their functions, then OK.
III: Loose coupling
As one of the military rules of software design. The less association each part has, it means you can perform testing, integration, and maintenance more easily.
IV: Scalable
In the old saying, the only thing that makes software is change. If your work is unsuitable for changes, you can basically add unqualified tags. Maybe you will say that I can change the code. Of course, you may need to modify the code, but there is one in the object-oriented design principle that the class can be extended and cannot be modified. Extensions are generally considered through inheritance. Modifications, especially interfaces, often cause many inexplicable problems. In short: When you add features to your software, you should not be right about the underlying architecture or even the architecture.
V: High fan inbound
Fan in? What is fan-in? I did not know before (My major is physics, and I am a programmer writing code !) A closer look refers to being referenced by other classes or methods. That is to say, your class/method is referenced by many other classes. That is, the utilization rate is very high. According to my idea, if I write a code segment three times, I will use it as a method or class separately.
VI: Low fan-out
Fan-out is to reference other classes or methods. According to Uncle Bob, the higher the fan-out is, the more unstable the class is. Because any referenced object has a problem, the class will have a problem. In addition, McConnell said: If the reference is more than seven, the fan is out.
7: Portable
In this case, I think we still need MVC. If the customer asks you to switch from B/S to C/S one day, you will be busy. I think the brother who likes to write logic on the page has to pay special attention to this. It seems that writing code without double-clicking can save a lot of trouble.
8: Streamlining
Not much can be done. You can't think that the factory model is so good that everything is okay. This is wrong. Yan Xin, who wrote "The path to mountain migration", also said that programmers cannot perceive that a function may be useful to you. this increases the number of tasks for testing, and Programmers think that users tend to dislike the tasks.
IX: Hierarchy
Hierarchy. The most common thing is the three-tier architecture. There are several advantages. You don't have to worry about the upper layer when you change the database. There is also a better division of labor. The elementary code written by inexperienced young people can be confined. In the future, if you want to rebuild it, you can rebuild it. If you want to change it, you can change it. This reduces the complexity.
10: Use standard technology
This will give you a feeling of familiarity. if the same framework is used, the same standard should be used for the code style. You can apply the same design pattern instead of the whole new pattern. After all, it is easy to understand the familiar things.

I think we can add one more point to the code,
11: High Cohesion
That is to say, a class, especially a method, should focus on one thing. For example, your I boyfriend Yes Companion girlfriend () Method, but not Write code () Method. Because Write code () The method is I programmer Interface only.
In Companion girlfriend () You cannot change Spend money This operation is added, because sometimes my girlfriend is at home with her. Watch TV Naturally Spend money 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.