Overview of Object-Oriented Design Principles

Source: Internet
Author: User

For the design of object-oriented software systems, improving system reusability while supporting maintainability is a crucial issue, how to Improve the maintainability and reusability of a software system at the same time is one of the core issues that need to be addressed in object-oriented design. In object-oriented design, the reuse of maintainability is based on the design principles. Each principle contains some object-oriented design ideas that can improve the design level of a software architecture from different perspectives.

Object-Oriented Design Principles were born to support maintainability reuse. These principles are embodied in many design patterns and are guiding principles summarized from many design schemes.. The object-oriented design principle is also one of the important indicators for us to evaluate the use effect of a design model. In the learning of the design model, we often see statements such as "XXX mode conforms to XXX principles" and "XXX mode violates XXX principles.

The seven most common object-oriented design principles are shown in the following table:

Table 1 seven common object-oriented design principles

Design Principle Name

Definition

Usage Frequency

Single Responsibility Principle

(Single responsibility principle, SRP)

One class is only responsible for the corresponding responsibilities in one functional area

★★★★☆

Principle of opening/closing

(Open-closed principle, OCP)

The software entity should be open to expansion and closed to Modification

★★★★★

Rishi replacement principle

(Liskov substitution principle, LSP)

All objects that reference base class objects can transparently use their subclass objects.

 

★★★★★

Dependency reversal Principle

(Dependence inversion principle, DIP)

Abstraction should not depend on details, and details should depend on abstraction

★★★★★

Interface isolation principle

(Interface segregation principle, ISP)

Use multiple dedicated interfaces instead of a single total Interface

★★☆☆☆

Merging Reuse Principle

(Composite Reuse Principle, CRP)

Try to use object combinations instead of inheritance for reuse purposes.

 

★★★★☆

Dimit Law

(Law of Demeter, D3S)

A software entity should interact with other entities as little as possible

★★★☆☆

[Author: Liu Wei http://blog.csdn.net/lovelion]

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.