In most cases, we are faced with the background is:
Designers of high, non-食人间烟火, only bound not to do, we must do, rather than the provision of methods and can reuse the API.
Developers to solve the problem is in the front line, suffered a repeat of the sufferings of the wheel-made, what they need is to solve the problem quickly in order to work more appropriate way to find it easier to build the technology and methods.
Jquery to the designers on a very good lesson.
Jquery is like a magician, like, $ () just like the magic wand, with the手一指, a puppet change resurrection, the moment has a wide range of complex capacities.
1) separation and adhesion
Jquery, who has been in the embodiment of dripping. Separation is not only a structure (structure) and function (behaviour), while stressing the separation of colleagues, provides a powerful connection, bonding capacity.
1. Structure <div> </ div>
2. Function function tooltip () ()
3. Bonding $ ( "# div_portlet"). Tooltip (); / / for the developers, and his party reached the design code of the hierarchical and functional separation of the two objectives to achieve.
The same is the use of traditional javacript library, the so-called practice of OO are as follows:
<script> var tootip = new Tooltip (); / / create OO object </ script>
<div> </ div>
Comparison between the two, we can see, Jquery very, very considerate of the developers, the adoption of strong cohesion of the API design, packaging, re-package, a method has been arranged two onmouseover and onmouseout events of things擦屁股resolved .
To imagine the past, is how to do a round table or a DIV, and a lot of CSS + The program is rounded picture, it is troublesome, but also consistent with the picture of the background page color of the environment.
jquery is how do :$("# div_portlet "). corner (); / / get, no CSS, no need for pictures.
2) Packaging, packaging, re-package
Write less. Do more, is the slogan of Jquery.
Every designer should also be borne in mind API Design, API design is to aim, I have a hard time, the spirit of the well-being of countless people. 【See a good thing to do in the end, we need the full stack design】 API.
Some people say that, Jquery code is too messy, really闲工夫, I still Javaeye forum, others have seen that arbitrary code Spring, also said the code as JBPM-Tropsch feces. The framework of these great, are the complexity of their own package, to the most simple API left to users, allows you to focus on their own to do. Is criticized in return.
Unfortunately, we use other people's libraries are always a lot of things to do, to complete a complex function.
For example, we show the Flash Object in use swfObject.js code needs to be done is:

<script type="text/javascript">
var so = new SWFObject ("../ open-flash-chart/open-flash-chart.swf "," ofc "," 250 "," 200 "," 9 "," # FFFFFF ");
so.addVariable ( "data-file", "../data-files/data-60.txt");
so.addParam ( "allowScriptAccess", "always" );//" sameDomain ");
so.write ( "my_chart");
</ script>
Similarly the use of JQuery jQuery Flash Plugin, a code to get.
$ ( '# hello'). flash (
(Src: 'hello.swf'),
(ExpressInstall: true)
);

3) make full use of barbed (hook), callback (callback) custom behavior
The default behaviour in the API can not meet the requirements of, the use of hook, callback, allows the caller of the API, you can do to maximize their own custom, add your own special behavior. Jquery the core, Plug-in, have a lot of use of such skills.
Such as: $ ( "div_content"). Toggle (); / / default is to switch between the two acts of hide and dispaly.
If you want to switch when other things do something. Such as notification of another control.
Can be: $ ( "div_content"). Toggle (function () (
/ / Can send messages, or starting the incident.
));

4) to reduce the number of lines of code is to reduce the complexity of the most effective way to
http://www.netvibes.com is a portal site, it Mootool the portal using the javascript framework, javascript in the head office the number of nearly 60,000 lines. OO has really done the Mootool well known as suitable for use in large, complex applications, but in complex applications, the over-OO, does not provide simple functionality, but the abuse of the succession of an increase of complexity and difficulty of maintenance .
Down down the code I looked at that if you are using Jquery, code at least half of the narrowing.

If you must insist on the application of your javascript application of large-scale (although there is no standard measure), you would like the Class, do not see this word, you a bad mood. See the following text.
5). OO and the combination of JQuery
Many people do not understand OO, the OO is it a double that OO, is that there must be a Class, and then continued to the new to new, and this is OO programming. Utility was originally a way to have to OO, the results of a new first Object, and then call the method Ojbect.
OO is it so? Of course not, packages, inheritance, polymorphism, is the core of OO.
OO programming to help users to develop highly flexible, easy to expand in order to safeguard the process, but only to understand OO.
If we are not satisfied with the Jquery use API, plug-in's function, we want to use it as our OO-based development of large-scale projects based on javascript frameworks, we can still plug-in manner, so that with a OO for JQuery the basis of the framework-way function.
Low Pro for jQuery is a prototye OO simulation of Jquery plug in, is that you can use the OO way of programming Prototype.
API prior to the use of plug-way call
$ ( '# example4'). draggable ((helper: 'clone', revert: true));
Suppose we encounter a complex situation, draggable want to change the situation, which is only modified source files.
The use of plug-ins, we can, through class inheritance to change the object type of behavior.
Draggable = $. Klass ((
initialize: function (options) (),
onmousedown: function () ()
));
Objects through inheritance to extend the act:
GhostedDraggable = $. Klass (Draggable, (
onmousedown: function ($ super) (
$ super ();
/ / Here can write custom code of conduct
)
));
Then attach to the development of the method of binding on the DIV:
$ ( 'div.product'). attach (GhostedDraggable, (anOption: thing));
6). In the application, as far as possible the use of a framework for technology accumulation.
Jquery satisfy the requirements of the majority, not to do so, is that you do not know, you do not know the Jquery just such a capacity.
I have recently done a Portal project, javascript is based on all the Jquery, see the figure below.
The use of plug-ins are not many, they are practical.
JTab, Draggable, Selectable, Sortable, Jcorner, Jtip
The chart is based on Jquery, but after holding them improved.
As for our style of programming based on the jquery goes without saying.