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
metamorphosis. So what exactly is object-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
Five basic principles:Single Duty principle (Single-resposibility Principle): A class, it is best to do only one thing, only a change that causes it. The principle of single responsibility can be regarded as the extension of low coupling, cohesion in object-oriented principle, defining responsibility as the cause of change, in order to improve cohesion to reduce the cause of change.Open closure principle (O
C # overview of the object-oriented design model (1): Face-to-Face Design Model and mongo.zip
Lecture content: this training course introduces the basic concepts and principles of
1. Change is the natural enemy of reuse!The biggest advantage of object-oriented design is that it resists change2. Re-understanding Object-orientedUnderstanding Isolation Changes:From the macro level, the object-oriented approach
1. Creation Mode:
Singleton: Solves the number of instantiated objects, such as factories and object pools in the abstract factory. In addition to Singleton, other creation modes solve the coupling relationship brought by new.
Abstract Factory: creates a series of interdependent objects and can change the series at runtime.
Factory method: create a single object, which is used in abstract factory.
P
1. Why to use C languageUntil today, although the C language is not the most used language, but C is not old, in many core system code, still running is beautifully designed C, the vast majority of embedded development core library software is developed by C, most of the sta
mechanism to implement the multi-threaded Singleton ModeClass Singleton3
{
Public static readonly Singleton3 Instance = new Singleton3 ();
Private Singleton3 (){}}Class Singleton3_1{Public static readonly Singleton3_1 Instance = new Singleton3_1 ();
Private Singleton3_1 (){}
Static Singleton3_1 (){Instance = new singleton3_1 ();}}
Singleton mode ExtensionExtend an instance to N instances, such as the implementation of the Object pool.Transfers the c
(string audiotype) { switch (audiotype.tolower ()) { case ("MP3"): PlayMp3 (); break; case ("wav"): playwav (); break; } } }
Naturally, you will find this design very bad. Because it does not provide a minimum scale for future changes in requirements. If your design turns out to be the case, then when you're overwhelmed by the overwhelming demand change, you might want to get the
In the object-oriented programming of PHP, you will always encounter
Class test{public static function test () { self::func (); Static::func (); } public static function Func () {}}
But do you know the difference between self and static?
In fact, the difference is very simple, just need to write a few demo can understand:
Demo for self:
Class car{public static function model () { self::getmodel ();}
clause 32: Make sure your pubilc inherits the is-a relationship of plastic mold
Make sure public inheritance models "Is-a"
one of the most important rules for –c++ (OOP) object-oriented programming is that public inheritance (open inheritance) means "is-a" (a) relationship.
– If you make class D ("derived") Inherit class B ("Base") as public, you tell the c
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
purpose of declaring a non-virtual function is to make derived classes inherit the function interface and a mandatory implementation.
Corresponds to Scenario c.
Pure virtual functions, virtual functions, and non-virtual functions allow you to specify exactly what you want to inherit from derived classes.
Summary:
Interface inheritance and implementation inheritance are different. Under public inheritance, derived classes always inherits the base clas
Clause 32: Determine your public inheritance mold out is-a relationshipOne of the most important rules for object-oriented programming in C + + is that public inheritance (common inheritance) means is-a (is a) relationship.In the C + + domain, any function that expects to obtain an argument of the type base class (rega
Throw Overflow (); 22 23 V [Top] = C; 24 Top ++ ; 25 } 26 27 STACK: Pop () 28 { 29 If (Top = 0 ) 30 Throw Underflow (); 31 Top -- ; 32 Return V [Top]; 33 } From the above, we can see how to define a class. This is just a type of stack. Different types of stacks may have different implementation methods of push and pop, in this way, we can use the object-
BeforeFieldInit StaticSingleton () {}/// ///prevents a default instance of the/// class from being created. /// PrivateSingleton () {}/// ///Gets the instance. /// Public StaticSingleton Instance {Get { return_instance; } } }4.Singleton Mode ExpansionExtend an instance to multiple instances, such as an implementation of an object pool. Transfer calls from the New constructor
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.