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
setter method;
That is, the parameter in our set method is an abstract class or interface to implement the transitive dependency object.
(3). Interface declaration implements dependent objects, also called interface injection;
That is, the parameter is an abstract class or interface in the function declaration to implement the transitive dependent object, thus achieving the purpose of directly using the de
The general rule of design not only describes how to design a class, but also goes up to the design of the entire component and down to the design of a single method in the class.
Single Responsibility Principle-SRP For a class, there should be only one reason for its changes.
Pr
Single Responsibility Principle for Object-Oriented Design Principles (SRP)
This principle was once described in the books of Tom DeMaro and Meilir Page-Jones and called it cohesion ). They define cohesion as functional correlations between components of a module.
Single Responsibility Principle (SRP)
Single Resp
Today, I have posted all the five object-oriented design principles (SRP, OCP, LSP, dip, and ISP) that I have organized some time ago. I hope they will help you, I also hope to have more exchanges with you.
General principles (from: D
During this time, Arthur J. riel's "object-oriented design heuristics" was read, so the following object-oriented design principles were summarized as a reference:
All data should b
Single Responsibility Principle: one class, it is best to do only one thing, only one that causes its changes. The single responsibility principle can be seen as the extension of low coupling and high cohesion in the object-oriented principle. The responsibility is defined as the cause of change to improve cohesion to reduce the cause of change. There are too many responsibilities, and there may be more rea
content of another module (primarily data members), it is called content coupling. Is the worst kind of coupling.
Cohesion Poly-Low couplingWhy high cohesion and low coupling: reducing complexityCohesion 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)
in the association relationship. Even if you use interfaces and abstract classes for variable type declarations, parameter type declarations, method return type declarations, and data type conversions, do not use specific classes to do these things.In most cases, open and close, the Richter substitution, rely on the reversal of three principles to appear, open and close is the target, the Richter substitution is the basis, rely on reverse is the mean
From: Agile Software Development: Principles, models, and practices: Robert C. Martin, translated by Deng Hui]
Class Design Principles:(1) SRP, The Single Responsibility Priciple ):For a class, there should be only one reason for its change.
(2) OCP, The Open-Close Priciple principle ):Software entities (classes, modul
Tag: the link exists completely, and the English contact is sent to the entity.Law of Demeter)Also known as the least knowledge principle (LKP.This is a guiding principle for object-oriented programming. It describes a policy to maintain loose code coupling.The DEMETER rule can be simply described as: talk only to your immediate friends.That is, you can only talk to your "friends" directly.For Ood, it is al
A Brief introduction:
Command mode: The command pattern is divided into "requestor of the Command" and "Implementation of the Command". Make the request for the command and the implementation complete understanding decoupling.
Two Example:
Cook = $cook; Public Function Execute () {$this->cook->meal (); }}class Drinkcommand implements command{private $cook; Public function __construct (Cook $cook) {$this->cook = $cook; Public Function Execute () {$this->cook->drink (); }}/* * S
understood as a role. An interface can only represent one role, and each role has a specific interface. At this time, this principle can be called"Role isolation principle".
(2)If "interface" is understood as an interface in a narrow sense in a specific language, what the ISP expresses isThe interface only provides the behavior required by the client. The behavior that the client does not need is hidden. The client should be provided with an independent interface as small as possible, rather th
The principles of class design:
SRP (single responsibility principle) single Responsibility Principle:A class should have only one responsibility. The responsibility of a class refers to the cause of the change. If a class has more than one responsibility, there will be multiple reasons for this change, in fact, coupled with multiple irrelevant responsibilities, will reduce the cohesion of this class.
What is the Demeter principle? What role does the dimit principle play in class design?
Demeter principles
1. Definition: each software unit has only the minimum knowledge of other units and is limited to software units closely related to the unit.
2. Analysis
(1) The Demeter law means that a software entity should interact with other entities as little as possible. In this way, when a module is mod
Design principles
English expression
Description
Single Responsibility Principle
SRP, single Responsibility Principle
A reasonable class should have only one reason for its change, that is, a single responsibility.
Open-closed Principle
OCP, open-close Principle
The software should be closed for modifications and open for extensions
Dependency i
What is the basic object-oriented principle?Design principles are basic tools. applying these rules can enable yourCodeIt is more flexible, easier to maintain, and easier to expand.
C # basic object-
I believe that programmers who have been doing software development for a few years will have such a sigh: "the coupling of this program is too high and cannot be modified. If you really want to extend the function, you can only write it again! ", "This piece of code is too messy. I haven't understood it for a few days !", "The newly added function is useless to the original code !"......
I have heard a lot of such sighs, especially when performing maintenance or version upgrades. The root cause
1. Design Pattern: Summarize the successful reusable design schemes from many excellent software systems.
2. abstract classes as transformation objects: abstract classes cannot use the new operator to create objects, but non-Abstract subclasses must rewrite all abstract methods, the object declared by the abstract class can be the transformation
C # Object-oriented principles
One, interface-oriented rather than implementation [Code to a interface rather than to a implementation.]
Second, the use of a combination of priority rather than inheritance [favor composition over inheritance.]
Third, srp:the single respons
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.