Object-Oriented design principles

Source: Internet
Author: User

Internal Poly

Definition: How tightly the inner elements of a module are bound to each other.

Classification:

    1. Accidental cohesion (coincidental cohesion)
    2. Logic cohesion (Logical cohesion)
    3. Time to gather (temporal cohesion)
    4. In-Process poly (procedural cohesion)
    5. Information Cohesion (informational cohesion)
    6. Sequential cohesion (sequential cohesion)
    7. Feature cohesion (functional cohesion): Elements are all designed to accomplish the same single task. One of the best ways to get cohesive.
Coupling

Definition: the degree to which the modules depend on each other

Classification:

    1. No coupling
    2. Message coupling: A more ideal coupling
    3. Data coupling
    4. Data structure coupling
    5. Control coupling: such as factory class
    6. External coupling: Two modules are not directly aware of the other modules, and there is no direct interaction between the two modules, but through the conventional "Protocol", "format", "Interface" and so on to complete the Division of labor
    7. Global coupling
    8. Content coupling: When a module relies on the internal content of another module (primarily data members), it is called content coupling. Is the worst kind of coupling.
Cohesion Poly-Low coupling

Why high cohesion and low coupling: reducing complexity

Cohesion the low coupling means that the higher the cohesion the better, the lower the coupling the better: not because the high cohesion and the low coupling are conflicting.

Class design principles (SOLID)
    1. srp-single Duty principle (Responsibility Principle)
    2. ocp-Opening and closing principle (open-closed Principle)
    3. lsp-Richter Replacement principle (Liskov Substitution Principle)
    4. Isp-Interface Isolation principle (Interface segregation Principle)
    5. dip-Dependency Reversal principle (Dependency inversion Principle)

Object-Oriented design principles

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.