prototype methods are added to the sub-class.Instance1.colors.push (' black '); Console.log (instance1.colors); // [' Red ', ' blue ', ' green ', ' black '] // [' Red ', ' blue ', ' green ']instance1.getname (); // CSSbook instance2.gettime (); // -Note: A subclass that wants to add a prototype method must pass a prototype object, one way to add it through the form of a point syntax, or it will be directly assigned to an
Http://www.cnblogs.com/seacryfly/archive/2011/12/29/2305965.htmlOnly changes to the (unique) responsibility (requirement) of the class will cause the refactoring of the code.The single responsibility principle states that every module or class should has responsibility over a single PA RT of the functionality provided by the software, and that responsibility should is entirely encapsulated by the class.All its services should is narrowly aligned with the that responsibility. Robert
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
Object-oriented design is mainly for the maintenance of software, extensible, reusable and flexible. In the face of new requirements and changes can be the minimum cost to achieve the best results.The object-oriented design is fur
in the past, the class in the program has been used to encapsulate the inheritance polymorphism is object-oriented design, but it is notencapsulation, inheritance, polymorphism is only the three main object-oriented features, but in the
This article to you to share is the PHP object-oriented three basic characteristics and five basic principles, the need for friends can refer to the content of the article
The three main characteristics are: encapsulation, inheritance, polymorphism
encapsulates , which is to encapsulate objective things into abstract classes, and classes can make their own da
Always think that the class in the program is used to encapsulate the inheritance polymorphism is object-oriented design, is notencapsulation, inheritance, polymorphism is only the three main object-oriented features, but in the design
underlying modules, both of which are dependent on abstraction. Depending on the abstraction, it is programming the interface, not programming the implementation.Dependencies are bound to exist between classes and classes, modules, and modules. When there is a tight coupling between the two modules, the best way is to separate the interface and implementation: To define an abstract interface between dependencies so that the high-level module calls the interface, and the underlying module to imp
Disclaimer: the object-oriented programming principles listed below are not my personal summary, but my notes on recent design patterns. Currently, only a few items are listed. You can continue to add them later.
1. Single Responsibility Principle (SRP)
The single responsibility principle is that, for a class, there sh
abstract the public part into a base class interface or abstract class, and to support the same responsibilities in a subclass by extract the method of the parent class through the abstraction class.The Liskov substitution principle is about the design principle of the inheritance mechanism, violating the principle of Liskov substitution inevitably leads to violating the principle of open closure.The Liskov substitution principle can ensure that the
ISP, Interface segregation principle.Interface isolation principle".
Like the dip principle, the ISP principle was proposed by the famous Martin. In 1996, he published an article titled "The interface segregation principle" in C ++ reporter, which elaborated on the ISP principle, in addition, in his classic book agile software development, principles, patterns (Chinese Translation: Agile Software Developme
error, we can see that the above method for global variables did not establish a namespace, global variables for us to pose a danger. So the above wording is right, let's verify:
Copy Code code as follows:
var box = {
Width:2,
Height:2,
Getarea:function () {
The access to the object in return This.width*this.height;//js must be displayed, that is, this is not omitted
},
Init:function (w,h) {
This.width = W;
This.height
Js object-oriented design: {} is good or function () {} is good. You have replied and I feel good. I would like to share it with you. I have read many JavaScript projects on the Internet, and the objects used are in the form:
For example, jQuery and TinyMCE all have the following shapes:
The Code is as follows:
Var Dialog ={Int: function (){....},Insert: funct
Putting these two concepts together is really not neat. But for those who are keen on design, we only need to use it.
First, we will explain these two concepts. What Is Oo? Haha, maybe everyone will laugh at me. Oo, who doesn't know? Don't talk to me about encapsulation/Inheritance/polymorphism! These are all so-called features. My question is: what is oo doing? For example, suppose you are a project manager. Now you have a task on hand that you need
parent class parameter, and the runtime invokes the parent class method to determine the specific internal structure or behavior through the passed-in subclass.The five main principles of object-oriented:(1) Single Responsibility principle ( single-resposibility Principle )? A class should have only one reason to cause it to changeEmployee Class Examples: For ex
example in the textbook, in the end, in order to bond these beautiful codes together, the layers become increasingly thick until they become sleepy.
C language itself is considered a good example of thin gluing layer.
UNIX and object-oriented languages
Since the middle of the 1980 s, new languages have claimed to provide direct support for
Understanding the three basic characteristics of object-oriented is the basis of understanding the five basic principles of object-oriented.Three major features are: encapsulation, inheritance, polymorphismThe so-called encapsulation, that is, to encapsulate objective things into abstract classes, and classes can be th
independent of each other, and there is no (or little) dependency between them.The Dimitri law does not want the class directly to establish direct contact. If there really is a need to establish a connection, it is also hoped that it will be conveyed through its friend class. Therefore, one of the possible consequences of applying the Dimitri law is that there are a large number of intermediary classes in the system that exist solely to convey the mutual invocation relationship between classes
. Development of the project Charterall members must abide by the Convention, uniform, improve the development efficiency, this can only be simulated fantasy only ... 4. Package Changes(1). Encapsulates the same changes into an interface or abstract class.(2). Package different changes into different interfaces or abstract classes. Reference book "Zen of Design Patterns"I'm a rookie, I'm on my way. Copyright NOTICE: This article for Bo Master original
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.