javascript - Is jQuery an implementation of the Decorator Design Pattern? -


it decorates objects, think is, i'm not sure.

example

jquery(document).hide() 

changes document object adding style.

edit:

if not decorator design pattern? it? there must pattern name it!

jquery best fits facade pattern, "define higher-level interface makes subsystem easier use." example, .css() , .hide() features designed ease of use, , jquery's ability perform action multiple elements @ once:

$('.foo').css({left: '100px', top: '100px'}).hide(); // jquery  // pure javascript for(var = document.getelementsbyclassname('foo'), = 0; < a.length; ++i) {     a[i].style.left = '100px';     a[i].style.top = '100px';     a[i].style.display = 'none'; } 

jquery seems fit decorator pattern in such ways animation functionality. normal html dom elements not offer timed animations , attached queues, jquery adds that. in other areas, jquery provides same functionality available accessing underlying dom elements directly.

but there, doesn't fit, jquery not "dynamically keeping same interface."


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -