Principles to be followed when designing a software development

Source: Internet
Author: User
Tags abstract
Software Development Principles Opening and closing principle ( OCP )The open-closed principle (OCP) is the cornerstone of "reusable design" in object-oriented design, and is one of the most important principles in object-oriented design, and many other design principles are a means to realize the open-closed principle. In 1988, Brant Meyer (Bertrand Meyer) proposed the open and closed principle in his book, Object-Oriented software architecture (object Oriented software construction), which is the original text: "Software Entities should is open for extension,but closed for modification ". The translation is: "Software entities should be open to the extension, the modification is closed." This is a little bit more professional, we make it more popular, that is: The software system contains a variety of components, such as modules (Modules), classes (Classes) and Functions (Functions), and so on, should not modify the existing code on the basis of the introduction of new features. "Open" in the principle of opening and shutting, refers to the expansion of the function of the component is open, is allowed to expand its function, the opening and closing principle of "closed" refers to the original code modification is closed, that is, the original code should not be modified. The principle of substitution on the Richter scale ( LSP )One of the fundamental principles of object-oriented design of the Richter substitution principle (Liskov Substitution Principle LSP). The Richter substitution principle says that where any base class can appear, subclasses must be able to appear. The principle of substitution on the Richter scale is a supplement to the principle of "open-closed". (polymorphic) Dependency Reversal principle ( DIP )The so-called dependency inversion principle (dependence inversion Principle) is to rely on abstraction and not rely on specifics. The simple thing is to ask for an abstraction for programming, not for the specific programming, thus reducing the coupling between the customer and the implementation module. Process-oriented development, the upper layer calls the lower layer, the upper layer relies on the lower layer, when the lower level of drastic changes in the upper layer also to follow the change, which will lead to the reduction of the module reusability and greatly improve the cost of development. Object-oriented development is a good solution to this problem, in general, the probability of abstract change is very small, so that the user program depends on the abstraction, the implementation of the details are also dependent on abstraction. Even if the implementation details are constantly changing, the client program does not need to change as long as the abstraction is constant. This greatly reduces the coupling between the client program and the implementation details. (for abstract programming, interface-oriented programming), parent control, child do not control parent。 Dependency reversals can also be called control reversals. Interface Isolation principle ( ISP )Using multiple specialized interfaces is better than using a single total interface. The dependency of a class on another class should be based on the smallest interface. An interface represents a role, and different roles should not be handed over to an interface. Interfaces that are not related are combined to form a bloated, large interface that is polluting the roles and interfaces. "Customers should not be forced to rely on methods that they do not use. The interface belongs to the customer and does not belong to the class hierarchy in which it resides. "Don't force customers to use methods they don't, and if you force users to use methods they don't use, then these customers will face changes due to changes in these unused methods." Synthetic / The principle of aggregation multiplexingThe synthesis/aggregation multiplexing principle (composite/aggregate reuse Principle, CARP) is often called the synthetic multiplexing principle. The synthesis/aggregation reuse principle is to use some existing objects inside a new object to make it part of the new object, and the new object is to reuse the existing functionality by delegating to those objects. Its design principle is to use composition/aggregation as much as possible, and not to use inheritance. Dimitri Law (loose coupling)The Dimitri rule (law of Demeter) is also known as the least known principle (Least knowledge Principle shorthand LKP), which means that an object should have as little knowledge of other objects as possible without speaking to strangers. The English shorthand is: The LOD Dimitri Law can be said simply: Talk only to your immediate friends. For Ood, a software entity should interact with as few interactions as possible with other entities. Each software unit has only minimal knowledge of the other units, and is limited to the software units that are closely related to the unit. The purpose of the Dimitri law is to reduce the coupling between classes. Since each class minimizes its reliance on other classes, it is easy to make the functional modules of the system independent of each other (or few) dependencies
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.