Discover api design best practices, include the articles, news, trends, analysis and practical advice about api design best practices on alibabacloud.com
Atitit. log system principles and design and best practices.
1. log system is an indispensable unit test, tracking debugging tool 1
2. The log system framework should generally include the following basic features 1
1. The output log has its own category. 2
2. logs are divided into different levels according to certain standards. 2
3. multithreading is supported. 2
4. Stability. 2
3. An Ideal log Mode 2
4.
class.PackagingThe purpose of encapsulation is to hide information, encapsulation should be considered "any form of encapsulation", that is, encapsulation is not only hidden data, but also the hidden implementation details, design details and types of hidden objects.Prototype modeIn JavaScript, each object is cloned from the Object.prototype object, so that we can only get a single inheritance relationship, that is, each object inherits from the Obje
data columns cannot be defined in frequently queried tables, which is based on performance considerations. Separate the data into separate tables. Then use the reference to point to the data, which is the associated query.
19, must use the database design third normal form normalization request, optimizes the performance. Not using a paradigm will result in too much duplication of data in too many tables, overuse of the paradigm will cause too many t
; One } A - varcalculate =function(Func, salary) {//Higher order functions - returnfunc (salary); the }; - -Calculate (S, 20000);//Output: 80000 -Calculate (A, 10000);//Output: 30000Or use objects so that policies can relate to each other:1 varLv = {2"S":function(Salary) {3 returnSalary * 4;4 },5"A":function(Salary) {6 returnSalary * 3;7 },8"B":function(Salary) {9 returnSalary * 2;Ten } One }; A -
prototype programming paradigm
If the object cannot respond to a request, it will delegate the request to its own prototype
object.prototype , which is an empty object, every object we encounter in JavaScript is actually cloned from it. object.prototype is their prototype. Although we often use new to instantiate a function, in JavaScript, when you use the new operator to invoke a function, you actually clone the object.prototype object First, and then pe
attaches great importance to the guidance of programming styles. It is extremely important to establish a good aesthetic. Kent Beck: "I'm not a great programmer; I'm just a good programmer with great habits. "Deng Hui, translator of Agile Software Development: Principles, models, and practices, has his opinion:" code quality is the most direct and fundamental embodiment of software quality, the so-called design
Analysis of Android source code design patterns and practices (16)Chapter 2 visitor Mode
Visitor mode is a behavior mode. It is the most complex of the 23 design modes. Although the frequency of use is not high, it does not mean that it can be ignored, it brings unexpected flexibility. Visitor mode, as the name implies, with this mode, you can add additional "v
Analysis of Android source code design patterns and practices (13th)Chapter 2 memorandum Model
The memo mode is a behavior mode that stores the current state of an object and can be restored to this State later. It is a bit like what we usually call "regret ".
1. Definition
Capture the internal state of an object without interrupting the closed state, and save the state outside the object. In this way, th
Analysis of Android source code design patterns and practices (9)Chapter 9. Responsibility Chain Model 1. Definition
The responsibility chain mode is one of the behavioral design patterns. It gives multiple objects the opportunity to process requests, thus avoiding the coupling relationship between request senders and recipients. Connect these objects into a chai
the complexity of some calls, but they also enhance the flexibility of iterators, and we can manually control the process or order of iterations.4. The iterator pattern can not only iterate over algebraic groups, but also iterate over the objects of some class arrays.In JavaScript, the for-in statement can be used to iterate over the properties of an ordinary literal object.5. Reverse Iterator6. Abort iterator7. Application examples8. SummaryThe iterator pattern is a relatively simple pattern t
Database design is one of the key points of the entire program. In order to support the relevant program running, the best database design is often not achieved overnight. It is a complicated process that can only be repeatedly explored and gradually refined, it is also a process of planning data objects in a structured database and the relationship between these data objects. The following provides 20 best
Introduction: Database design is one of the key points of the entire program. In order to support the relevant program running, the best database design is often not achieved overnight and can only be repeatedly explored and gradually improved. This is a complicated process, it is also a process of planning data objects in a structured database and the relationship between these data objects. The following
Database design is one of the key points of the whole program, in order to support the relevant program operation, the best database design is often impossible, can only repeatedly explore and gradually refinement, this is a complex process, but also the planning and structured database data objects and the relationship between these data objects process. Here are 20 database
=function(){ This. Receiver.add ();};varDelsubmenucommand=function(receiver) { This. receiver=receiver;};D ElSubMenuCommand.prototype.execute=function{ This. Receiver.del ();}Finally, the command receiver is passed into the commands object, and the order object is bound to the buttonvar refreshmenubarcommand=New Refreshmenubarcommand (MenuBar); var addsubmenucommand=New Addsubmenucommand (submenu); var delsubmenucommand=New Delsubmenucommand (submenu); SetCommand (button1, Refreshmenu
and polymorphism.The policy model provides perfect support for the open-closed principle, encapsulating the algorithms in separate startegy, making them easy to switch, easy to understand, and easy to extend.Algorithms in the policy model can also be reused elsewhere in the system, avoiding many repetitive copy-pasting efforts.Using composition and delegation in the policy model allows the context to have the ability to execute algorithms, which is a more portable alternative to inheritance.In
iterator: Sets the callback function to the callback to return false when it jumps out of the loopExamples of applications for iterators: When file uploads are available in many ways, avoid using conditional selection statements to choose how to uploadThe solution might be:
Each upload method is written as a function, the function returns the Upload object, and returns False if it is an incompatible upload method.
Iterate through all the functions of the upload method as an array,
Web-side when a large number of DOM data insertion, if a one-time insertion of thousands of data, the browser will be unable to appear in the case of the death of Kaka, the code is as follows:vararr = []; for(vari = 0; i ) {Arr.push (i);}varLoadData =function(data) { for(vari = 0, L = data.length; I ){ varElem = document.createelement (' div '); Div.innerhtml=i; Document.body.appendChild (DIV); }};loaddata (arr);//Create a Timechunk () function to insert the DOM in batchesvarTimechunk
interface object, everyone is this interface object, but a layer of layers, constantly called.The execution process is actually a depth-first search .some notable places to watchThe combined pattern is not a parent-child relationship, but rather a delegate relationship.Scenario: The combination mode is only appropriate when dealing with each leaf object in the list in a consistent manner.SummaryCombining patterns allows us to create the structure of objects in a tree-like way, and we can apply
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.