object-oriented design process, under specific scenarios, and between classes and communicating with each other.? A deep understanding of object-oriented is the basis of learning design patterns, mastering certain
reasons such as the need to modify the original code of the software, may introduce errors in the old code, or we will have to refactor the entire functionality, and the original code needs to be tested again. This has a special impact on our entire system, which also fully shows the coupling of the system if too high, will greatly increase the later expansion, maintenance. In order to solve this problem, people have summed up the principle of opening and closing. The fundamental solution to th
Introduction to the six principles of object-oriented design and six major object-oriented design
In fact, they all complement each other. That is to say, some
, which is inherited and implemented by the service class.
Figure 5 service class design separated by interfaces
If the method for Customer A is changed, Customer B and customer C will not be affected or need to be re-compiled or re-released.
The above four principles are commonly used in object orientation. I
: This article mainly introduces (5) Object-Oriented Design Principles 1 --- general principles and single responsibility principles. if you are interested in PHP tutorials, refer to them. I. general
Seven major object-oriented design principles (Transition) and seven major design principles
I. Single responsibility principle:
Full name: "Single-Responsibility Principle"
Object-
Seven main object-oriented design principles
Opening and closing principles : In the face of demand, changes to the program is done by adding new code , rather than changing the original title
dependency Reversal Principle : High-level modules should not rely on the underl
doesn't answer the fundamental object-oriented question-Why do we use object-oriented objects. How should we use the three mechanisms to achieve "good object-oriented". What kind of object
package, it will affect all classes in the package, but it will not affect other packages.
Package coupling principle
No-ring dependency principle (Acyclic Dependencies Principle, ADP)
The package dependency does not allow loops.
Stable-Dependencies Principle, SDP)
Dependency in a stable direction
Stable-abstractions principle (SAP)
The abstraction level of the package should be consistent with its stability.
Old ti
project, the organization defines
The name of the class, you need to follow certain rules, preferably with the class name as the center, or you can add a uniform prefix or suffix shape
into filenames, such as xxx_classname.php, classname_xxx.php, and classname.php, and so on.
This example attempts to load the MyClass1 and MyClass2 classes from the myclass1.php and myclass2.php files, respectively
Code Snippets
Copy the Code code as follows:
function __autoload ($classname) {Require_once $c
I. Design Principles1. Dependency inversion principle (DIP)
High-level modules (stability) should not depend on low-level modules (changes), both of which should depend on abstraction.Abstract (stable) should not depend on implementation details (changes), and implementation details should depend on abstraction.
2. Open and closed principle (OCP)
Class modules should be extensible, but cannot be modified; open to extensions and closed to changes
the final implementation of the object-oriented design pattern is still expressed in the object-oriented programming language, which is based on the C # language, but in fact it is suitable for support. NET Framework for all. NET
Original Author: Robert C. Martin
Original article: http://www.objectmentor.com/resources/articles/Principles_and_Patterns.pdf
Reference page: http://www.objectmentor.com/resources/publishedArticles.html
Ii. Object-oriented Design Principles
1 The Open-Close princ
In the previous Java 23, you learned about the singleton mode and Factory mode of design mode. Here, the design pattern is introducedPrinciple of object-oriented thought designIn the actual development, we want to understand the object-o
that the structure of the program is starting to become loose. Any change to the input or output device will force you to re-organize the condition judgment of the while loop. But after all, your program can work normally. But now you have reached the bottom line. If a hateful customer breaks your design by changing the demand, you will leave immediately. You made up your mind.
Your crash ......
Unfortunately, it didn't take two weeks. You did
Object-oriented design principle principle objective object-oriented design original table single Responsibility principle case Closed-closing principle case dependence reversal principle caseObject-
The merging Reuse Principle is also known as the composition/aggregate Reuse Principle and carp principle. Its definition is as follows:
Composite Reuse Principle (CRP): Use object combinations as much as possible instead of inheritance to achieve reuse.
The merging Reuse Principle is to use some existing objects in a new object through the association relationship (including the combination
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.