Object-oriented (OOD) Design Principles (I): overview

Source: Internet
Author: User
Ood design principles Overview:

 Robert tcecilmartin,Bertrandmeyer,Barbaraliskov11 object-oriented design principles are put forward, which are regarded as the good bible by Object-Oriented designers. They can see their original text below:

Http://c2.com/cgi/wiki? Principlesofobjectorienteddesign

Http://www.objectmentor.com/

Class Design Principles ):

  1. Single Responsibility Principle (SRP ):A class should have only one reason to change.(SRP) The single responsibility principle:A class shoshould have only one reason to change.
  2. OCP ):Software entities (classes, modules, functions, etc.) should be extensible, but cannot be modified.
    (OCP) The open-closed principle:Software entities (classes, modules, functions, etc.) shocould be open for extension, but closed for modification.

  3. Liskov replacement principle (LSP ):The subclass must be applicable to the base class, that is, the subclass must be able to replace the base class, otherwise.
    (LSP) The liskov substitution principle:Subtypes must be substitutable for their base types.

  4. Dependency inversion principle (DIP ):Abstraction should not depend on details, but on abstraction.(DIP) the dependency inversion principle:Specified actions shoshould not depend upon details. Details shoshould depend upon specified actions.
  5. Interface isolation principle (ISP ):Customers only need to focus on the interfaces they need, rather than forcing customers to rely on methods they don't need.
    (ISP) the interface segregation principle:Clients shoshould not be forced to depend upon methods that they do not use. Interfaces belong to clients, not to hierarchies.

Principles of package cohesion ):

  1. Reuse release Equivalence Principle (REP ):The granularity of reuse is the publishing granularity.
    (REP) the reuse/release equivalency principle:The granule of reuse is the granule of release.

  2. Common blocking principle (CCP ):All classes in the package should be closed for changes to the same class nature.(CCP) The common closure principle:He classes in a package shoshould be closed together against the same kinds of changes. A change that affects a closed package affects all the classes in that package and no other packages.
  3. Common Reuse Principle (CRP ):All classes in a package should be reused together.
    (CRP) The common Reuse Principle:The classes in a package are reused together. If you reuse one of the classes in the package, you reuse them all.

 Principles of package coupling ):

  1. No-ring dependency principle (ADP ):The package dependency graph does not allow loops.
    (ADP) The Acyclic Dependencies Principle:Allow no cycles in the package dependency graph.

  2. Stable dependency principle (SDP ):Dependency in a stable direction.(SDP) the Stable Dependencies Principle:Depend in the direction of stability.
  3. Stable abstraction principle (SAP ):The abstraction level of the package should be consistent with its stability.
    (SAP) the stable role action principle:A package shoshould be as abstract as it is stable.

 

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.