Object-oriented design patterns

Source: Internet
Author: User

Object-oriented design principles: seven Principles

1, single duty principle SRP

Definition: Every class in a system should have only one responsibility

Benefits: cohesion, low coupling

2, open and closed principle OCP

Definition: Open for extension, close for modification

Benefits: Adaptability and flexibility, stability and continuity, reusability and maintainability

3, Richter replacement principle LSP

Definition: Wherever the parent class appears, it can be replaced with its subclasses without affecting the function

4, dependency inverted principle dip

Definition: High-level modules should not rely on the underlying modules, both should rely on their abstraction;

Abstraction should not depend on detail; detail should depend on abstraction.

Benefits: Improve the stability of the program, maintainability, scalability.

5, interface isolation principle ISP

Definition: Using multiple specialized interfaces is better than using a single total interface.

Benefit: Do not force new features to implement unwanted approaches

6, Dimitri Principle lop

Definition: An object should have as little knowledge of other objects as possible

Benefits: Reduced COUPLING

Disadvantages: Reduced communication efficiency, resulting in a large number of intermediary classes

7, combination/aggregation multiplexing principle carp

Definition: Preferential use of the combination to make the system more flexible, followed by the consideration of inheritance, to achieve the purpose of reuse

Benefit: Fewer dependencies are required for composite multiplexing

Composite multiplexing can be performed dynamically during run time

Cons: The system will have more objects to manage

Object-oriented design patterns

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.