Is jQuery chaining a free programming example?

I'm a little new to JavaScript / jQuery, but when I saw the example chaining of methods, it seemed instantly familiar to me. Other interfaces, such as LINQ, do something similar if the type of the returned set of methods matches the type that they control (TweetSharp does something very similar). Is this an example of free programming? Most of what I read about jQuery says that other libraries have "borrowed" this idea of โ€‹โ€‹the method chain - did the idea come up with jQuery?

+4
source share
3 answers

jQuery really strongly follows the pattern / free interface , but it is certainly not a pioneer in the design pattern as a whole. Other libraries most likely followed jQuery and borrowed its approach. This is just the glory of jQuery, which makes it look like jQuery.

+6
source

Only the chain does not make a free interface. The term โ€œfree interfaceโ€ seems to have been popularized by Martin Fowler, one of the more prolific modern authors in software theory (although he doesn't come up with a technique).

Fowler explains that the method chain simply refers to methods that return an object reference, while the free interface is more akin to domain-specific language and (ideally) is intended to flow more like a natural language than code.

+2
source

JQuery, of course, did not invent the chaining method; this was already possible in JavaScript and many other languages.

The chaining method may have been legitimized in many jQuery eyes. Many Java programmers still insist that object functions should return only other objects, not the object itself. As I recall, 10 years ago I received a modification from the Java mailing list, suggesting otherwise :)

+1
source

All Articles