-oriented? Why should C + + add support for it? How does C + + support object-oriented? Don't worry, and listen to my one by one-way.6.1 From structured design to object-
.
During program design, we should always consider the best class design as much as possible, and do not modify it if it is well written. If there is a new demand, we add some classes to meet new requirements, and the original code will not move.
It is absolutely impossible to disable the modification. No matter how closed the module is, there will be some changes that cannot be closed to it. Since it canno
isolation, flexibility is poor, very inconvenient to use. According to their own system size, reasonable control interface.(2). Depending on the class selection method of the dependent interface, only expose to the calling class the method it requires, and the method it does not need is hidden. A minimal dependency can be established only by focusing on providing a customized service for a module.(3). Improve cohesion and reduce external interaction. Enable the interface to do the most things w
The seven fundamental principles of object-oriented:Principle a single duty principleSingle Duty principle (Srp:single responsibility principle) also known as single function principleCore: Decoupling and enhanced cohesion (cohesion poly, low coupling).Principle two: The principle of the Richter replacement (Lsp:liskov Substitution Principle)Core: Wherever the parent class appears, it can be substituted wit
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 combina
Ood design principles Overview:
Robert tcecilmartin,Bertrandmeyer,Barbaraliskov11 object-oriented design principles are put forward, which are regarded as the good bible by Object-
OCP principles in the field of Object-Oriented Design
Keywords: Object-oriented Design1. Introduction to OCP (OCP -- open-closed principle ):Software entities (classes, modules, functions, etc.) shocould be open for extension, but
Some principles of object-oriented design in Agile Software Development-principles, models, and practices:
Single responsibility principle:For a class, there should be only one reason for its change
Principles of openness and cl
: type [= default value]
Visibility method Name (parameter list) [: Return value type]
Examples are as follows:(3) The relationship between classes① Association Relationship1) bidirectional correlation. examples are as follows:2) One-way association. Examples are as follows:3) Self-correlating. Examples are as follows:4) Multiple sexual associations. Examples are as follows:5) Aggregation relationship. Examples are as follows:6) combined relationship. Similar to the aggregation relatio
/projects/structuremap/files/Ninject:http://ninject.org/downloadUsing the existing broad application framework above, spring.net originates from Java's Spring, is more complete and powerful, AUTOFAC and Ninject are more clear and friendly, personal recommendation use autofac+ other framework combination.4, interface Isolation principleRequirements: Use a dedicated small interface as much as possible, rather than the total interface, to avoid complex interfaces.5, the Richter replacement principl
define a large number of access methods in the public interface. A large number of access methods means that the relevant data and behavior are not centrally stored.
(15) Be more careful with classes that contain too much communication behavior. P31
Another manifestation of this problem is the creation of many get and set functions in the public interface of the classes in your application.
(16) In an application composed of an object-
can be simplified to 1 of the structure shown:In Figure 1, because of the complexity of the interaction between classes, the addition of new objects in the system requires modifying the source code of other classes that interact with it, the system is less extensible, and it is not easy to add and delete new objects.In this example, you can reduce the degree of coupling between objects by introducing a mediation class (mediator) that is designed to control interaction between objects. After the
tenable, such as a method MethodB accepts a subclass object of type ClassA as a parameter: MethodB (sub), then generally there is no MethodB (base), unless it is an overloaded method.Example: The Richter replacement of the data request for the Shenzhen-A-share plate: In this example, you can consider adding a new abstract class Stockblock, and Shanga and Shena classes as their subclasses, the data request class quote class for the a
Liskov substitution principle LSP is one of the basic principles of object-oriented design.
As mentioned in the Rys replacement principle, subclass can certainly appear where any base class can appear.
LSP is the cornerstone of inheritance reuse. Only when the primary class can replace the base class and the functions
abstract class or interface, so that the subclass inherits the parent class or implements the parent class interface, and implements the methods declared in the parent class. 4. Dependency reversal PrincipleDefinition:High-level modules should not depend on underlying modules. They should all rely on abstraction. Abstraction should not depend on details, but on abstraction.Dependency reversal principle requirements: programming interfaces rather than implementing programming. 5. Interface iso
Object-Oriented design principles:1. Single Duty principle (SRP): each class in the system should have only one responsibility. Benefits: cohesion, low coupling.2. Opening and closing principle (OCP): open for extension, closed for modification. Benefits: Increased adaptability and flexibility, stability and continuity
When using the object-oriented idea for system design, our predecessors summarized seven principles:
1. Single Responsibility Principle (SRP)
The core idea of a single responsibility principle is that every object in the system should have only one independent responsibility
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.