Learn about solid principles of object oriented design, we have the largest and most updated solid principles of object oriented design information on alibabacloud.com
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
Single Responsibility Principle-- SRP Open and closed Principle-- OCP LiskovReplacement Principle --LSP Dependency inversion principle-- Dip Interface isolation principle-- ISP Package Design Principles Reuse release Equivalence Principle(REP) The granularity of reuse is the publishing granularity. Principle of mutual Closure(CCP) All classes in the package should be closed for changes to the sam
no-ring dependency principle (ADP)
The package dependency graph does not allow loops.
N stable dependency principle (SDP)
Dependency in a stable direction.
N stable abstraction principle (SAP)
The abstraction level of the package should be consistent with its stability.
The concept of the above package is: the package can be used as a container to accommodate a group of classes. By organizing classes into packages, we can understand the design
class, the program will not crash and only result errors will be reflected on the interface.
The interface is only responsible for displaying,
Public partial class form1: FORM {public form1 () {initializecomponent ();} private void button#click (Object sender, eventargs e) {dictionary
This is just a simple requirement. For complex programs, for example, there are many main interface controls, you need to create another class formmanager, which
, the structure pattern, the behavior pattern, respectively from the object creation, the object and the object structure combination as well as the object interaction these three aspects for the object-oriented system modeling me
the programmer should have the-solid principle of artistic temperament. 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
Solid is an abbreviation for several important coding principles
Srp:the Single Responsibility Principle sole responsibility principle
Ocp:the Open Closed Principle opening and closing principle
lsp:the Liskov Substitution Principle Richter Replacement principleLd:the Law of Demeter Dimitri
Isp:the Interface Segregation Principle Interface separation principle
Dip:the Dependency Inversion Principle depen
() {transferer. expenditure (amount); payer. deposit (amount) ;}} class Start1 {public void Main () {bank account Zhang San = new bank account {card number = 111, balance = 10000 }; bank account Li Si = new bank account {card number = 222, balance = 5}; bank transfer operation transfer = new bank transfer operation (); Transfer. amount = 1000; transfer. transferor = James; transfer. recipient = Li Si; transfer money. transferring money () ;}} copying code S
the Mercedes-Benz class is a tight coupling relationship, which led to a greatly reduced maintainability of the system, the addition of new vehicles such as BMW BWM car will need to modify the driver class drive () method, this is not stability but variable. The change of the dependent person should allow the dependent to bear the cost of the change, Span style= "FONT-SIZE:14PX; line-height:27.2px; Text-indent:1em; " > So it can be implemented by the dependency inversion principle. As shown,
know the return type is ArrayList, only know to return the list, this is the Richter replacement principle;
Public list
The two examples listed above are the relationships between the interfaces in the collection and the implementation classes, that is, the relationship between the base class and the subclass. The function that the base class can implement, the subclass can replace the base class to implement the corresponding function, this is also the Java
I have found that object-oriented design is too serious to be overlooked. Use the OOP language, but not object-oriented design. It is nothing more than writing C programs with classes, and this is a common situation. The other is
Since the core of object design is the class, the following principles are basically the discussion of the design of the class, the other types of elements are relatively simple, basically also conforms to most of the principles listed here. Before we have analyzed the basic
The basic principle of object-oriented design http://www.cnblogs.com/malaikuangren/archive/2012/03/22/2411315.htmlInterface:Understand:An agreement between the parties.Benefits:interface and implementation separation;Easy to expand;Object-Oriented
I. DefinitionThe open and closed principle (OCP), which is the full name of open for Extention and closed for modification principle, that is, the principle of opening and closing for modification. The idea of this principle is that we can meet the changes through expansion without modifying the code, or when designing a module, this module should be extended without being modified.II. ImplementationAbstraction is the key to implementing the open/closed principle. abstraction is a core feature o
Object-Oriented Design _ C ++ 1 and object-oriented design _ c
Mastering a language is not suitable for me. I like to quickly master 50% of a language.
Three main features of object-
First of all, it must be stated that the viewpoint described in this article is only applicable to the implementation process of object-oriented systems based on the traditional waterfall model, this process includes feasibility analysis, requirement analysis, object-oriented analysis and
risk reduction, change is inevitable, if the single responsibility principle is good, when modifying a function, can significantly reduce the impact on other functions.One point to note is that the principle of single responsibility is not only specific to object-oriented programming ideas, but a single responsibility principle is applied to modular programming. 2, open closure principle OCP (Open-close pr
return New F ();}He is an encapsulation of class inheritance, in fact, the transition object is equivalent to the subclass in the class inheritance, but in the prototype as a transitional object appears, in order to create to return the new instantiated object.Of course, if you feel the need to cache the F transition, you don't have to create a new transition class F each time, and then the Object.create (
principles, In the final analysis, the goal of software design is to package change and reduce coupling, and the open closure principle is the most direct embodiment of this goal. The core idea of the Open closure principle is that software entities should be extensible and non-modifiable. That is, open to the extension, to modify the closed. Therefore, the open closure principle is mainly embodied
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.