); parent.goSchool(); parent.pay(); parent.getBook(); parent.goHome(); }}? Usually the beginning of the school report is very happy, because after all, just finished years, received a lot of lucky money, but also waiting to go to school flowers quickly. But Xiao Ming too much love, too little money, rather die than report, to Xiao Ming himself to the school report too difficult, Xiao Ming's parents had to replace Xiao Ming to register. Instead of Xiao Ming to enrol
interface injection;That is, in the function declaration, the argument is an abstract class or interface, which implements the transitive dependent object, thus achieving the purpose of directly using the dependent object.can be summarized as interface passing, construction method passing and Setter method is passed. The core of the dependency inversion principle is that we should interface programming, understand interface-
: 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 principles:
1. five object-oriented principles: single responsibility prin
engine does those things.
First, try traversing the properties in B, but not the Name property.
The request to find the name attribute is delegated to the prototype of the constructor of object B, which is b.__proto__ logged and points to B.prototype, and B. The prototype is set to an object created through new A ().
The name attribute is still not found in the
mind anyway)
Good encapsulation, (interface to reasonable, physical design for the fact, do not have much interface, many, good)
The granularity of the class should be reasonable
Consider the correctness of dependencies. (Do not reverse-rely on inverted errors, such as the design of the logical layer and the UI, you are in the logical class of the process relies on the interface of the UI layer an
in Iofile.However, virtual inheritance is not commonly used because:
1. Virtual inheritance increases the cost of space and time.
2. Virtual inheritance can be very complex (writing costs) because the virtual base class, either indirectly or directly inherited, must assume the initialization of these bases, regardless of how many layers of inheritance are.
Please rememberMultiple inheritance is more complex than single inheritance. It can lead to new ambiguity and the need for
expresses a specific object (type code) that affects the behavior of the class and may cause the branch statements associated with that type to appear frequently in the program, we should create a new derived class and use polymorphism instead of his
Refinement subclasses: Sometimes, some properties in a class only make sense for some instances of the object, which means that the class's plan is not p
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
in the use of object-oriented thinking system design, the predecessors summed up a total of 7 principles, respectively, are:
Single duty principle, open and close principle, Richter replacement principle, Dependency injection principle, interface separation principle, Dimitri principle and priority use combination rather than inheritance principle.
S.O.L.I.D is the acronym for several important coding principles (programming Priciple) in object-oriented design and programming (Oodoop).
SRP
the single Responsibility principle
single responsibility principle
OCP
the Open Closed principle
LSP
The Liskov Substitution Princip
S.O.L.I.D is the acronym for several important coding principles (programming Priciple) in object-oriented design and programming (Oodoop).
SRP
the single Responsibility principle
single responsibility principle
OCP
the Open Closed principle
LSP
The Liskov Substitution Princip
Document directory
Advantages and disadvantages of Combination
Inheritance
Inheritance/combination Example 1
Inheritance/combination Example 2
Rule 1: Prioritize (object) combinations, rather than (class) Inheritance
[Favor composition over inheritance]
Combination1. (object) combination is a method of reusing new functions by creating an object that comb
indexed in the return table return {withdraw = WI Thdraw, deposit = deposit, GetBalance = getbalance}enda1 = NewAccount (0) a2 = newaccount (+) A1.withdraw (+) print ( A1.getbalance ()) print (A2.getbalance ()) a Special "object": This can be used when the object has only a single method. It is a special case of the OOP described earlier, which is not inherited but private and efficient:function NewObj
of programming, which conforms to the normal thinking of people. If we drive a Mercedes Benz is dependent on the Mercedes-Benz, the use of laptops directly rely on notebook computers.② "Dependency inversion": programming is to abstract the real world things, and then we based on the needs of the system design to produce a dependency on the abstract, instead of people's traditional thinking of the dependence between things, called "inverted."3.2 Depen
Objective of the Object-Oriented Design Method
In system design, if the design personnel can achieve the following "six", that is, modular, role-oriented, process-oriented, standardi
: Design Two tables: A storage teacher, a storage student (the most common way)
Advantages: All this, the advantages of a lot of natural
Cons: Some queries are somewhat difficult to implement. (e.g.: Query for new teachers and students in the last time period and sort by time)
Object-oriented approach to impl
About the Great software:"Great software is always doing what the customer wants him to do," says the client-friendly program designer . As a result, customers will be able to pay the desired results even when they have a whim to use the software in new ways.The object-oriented programmer says: great software is object-orient
Object-Oriented Design UML practices:"An analysis model is different from a design model. It does not involve developing any characteristics of the system, but aims to capture some aspects and features of the business in the" real world.Generally, the analysis model describes the data processed in the application and v
Work needs to do a PHP module, the content of the various sections of the Forum to do statistics, and then data extraction. Each plate has some main topics or content to focus on. For example, the car section, will focus on safety, car maintenance knowledge, how to choose cars and so on. Then the car section of all the posts according to these concerns to classify, calculate points, statistics. Finally, some data are obtained for future data mining.
The problem is: There are many sections on the
I started to learn the design model and posted "design patterns can reuse the basis of object-oriented software" on the Internet. After reading the introduction, I found that I have written so many self-satisfied code before, however, from the perspective of the design model
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.