About

This is the default template for Pivot. You can change this text by editing the file frontpage_template.html in your pivot/templates/ folder. You can do this by directly editing the file, or you can go to Administration » Templates in the Pivot interface.

The image in the header is © Andreas Reinhold.

Archives

01 Jun - 30 Jun 2007
01 Nov - 30 Nov 2007
01 Apr - 30 Apr 2008
01 Jun - 30 Jun 2008
01 Oct - 31 Oct 2008

Links

Pivot Homepage
Pivot Forums
Pivotstyles
Pivot Help

To change the links in this list, edit the file '_aux_link_list.html' in your Pivot's templates folder. You can do this by directly editing the file, or you can go to Administration » Templates in the Pivot interface.

Search!

Last Comments

daiod (Class Inheritance…): diash hdiashid
king (Class Inheritance…): That was a great piece of…
king (Class Inheritance…): That was a great piece of…
DC hats (Class Inheritance…): That was a great piece of…
Charles Phillips (Class Inheritance…): Thanks to Aaron for the l…
Aaron Newton (Class Inheritance…): Also, I think you are per…
Aaron Newton (Class Inheritance…): Great post Charles. I t…

Stuff

Powered by Pivot - 1.40.4: 'Dreadwind' 
XML: RSS Feed 
XML: Atom Feed 

« We apologize for the … | Home |

Class Inheritance and jQuery

03 10 08 - 13:40 A post over at CNET Clientside Blog* (Aaron Newton) got me thinking...

jQuery gets a unfair bad rep for extensibility -- the sheer popularity of jQuery means that a large number of users aren't using jQuery to its full potential. I develop with jQuery the same way Aaron develops with MooTools -- when I see a pattern emerging, I create a plugin and extend jQuery. It's simple to create your above example -- just use jQuery.extend! (More detailed example here.)

He mentions to call a plugin method, the code would be:
"jQuery(domId).pluginName(”methodName”, [arg1, arg2]); - I hope I have that right."

It can be that way, but with a properly designed plugin it's as easy as:
$(domEl).plugin.method(arg1,arg2);

...And if you want full class behavior, with super/subclasses etc., Resig has thought of this as well:
http://ejohn.org/blog/simple-javascript-inheritance/

Also, it's been done for production. Here's a good read, a recent post about this exact topic by Dr. Danny Wachsstock.

Most of all, check out Dan Webb's port of Low Pro to jQuery.

The class issue has been discussed at length -- and solved -- in the Groups and other various forums. Therefore, I fail to see 'what really makes one framework different from another'... except that jQuery is much less verbose! Aaron's MooTools code (in the post) is nearly identical to jQuery -- except the 'addEvents' drive me nuts, thank goodness for .click() and other jQ event methods.

I think Resig feels much the same way I do about how class-based design can often be overly descriptive, and a waste of bytes.

In all seriousness, I don't want to start a flame war or framework competition any more than Aaron does. I just realized that there's so much to jQuery, even the Ajax Experience can't cover it all!! -- So I hope this brings to light another strength of jQuery and stops some FUD.

*[link corrected 10-Oct as per Aaron's comment below]

Charles Used tags: , ,
seven

Great post Charles.

I tried my best in my post not to make it about comparing MooTools to jQuery so much as talking about pattern based programming. One of my realizations was that there was nothing about jQuery that prevented this kind of programming (specifically, "class" based prototypal inheritance) and that really opened some doors for me in understanding how one might use jQuery to program the way I prefer to.

I sincerely don’t think of one framework as better or worse than the other, but I appreciate that MooTools is written this way as it resonates with my own style. That’s really all – it’s a style preference. Both frameworks accomplish many of the same things.

The only thing that MooTools has that the jQuery model doesn’t is that, in jQuery, I can’t easily extend a plugin that someone else wrote. In MooTools, if I need to extend, say, the ajax class, I can subclass it easily. I asked Richard Worth (jQuery contributor who spoke at Ajaxian) if this was possible and he said no, so that’s where I’m getting that info from; hope I’m not wrong in that statement.

I don’t view this as a flaw, it’s just something MooTools does that jQuery doesn’t. Tomato, tomahto. So when I say that this is something that makes jQuery different from MooTools (and one of the reasons for my preference), that’s all I’m saying: they are different.

I’ll post an update to my post with some of your clarifications. Good stuff.
Aaron Newton (URL) - 08 10 08 - 08:38

Also, I think you are perhaps linking to the wrong post. You’re linking to an announcement about some our plugins, but you seem to be replying to this: http://clientside.cnet.com/best-practice..
Aaron Newton (URL) - 08 10 08 - 08:50

Thanks to Aaron for the link correction – I was pulling links from many tabs and must’ve lost track. Updated above.

It’s good to have a comparative discussion of the frameworks’ strengths — as each framework grows and refines, we learn from one another and the differences are becoming smaller. As with Low Pro, if one framework has a major benefit, it’s often not long before the code is ported. I love Open development, it’s saved us all countless hours fighting the browsers.

I am often amazed at how far we’ve come, and yet how far we have to go. Being able to write-once run-almost-anywhere is the future, and I’ve been investigating Jaxer and other server-side JS solutions to that end. I think the next major competitive breakthroughs will come as the frameworks [continue to] adapt to running server-side and on mobile browsers (which are actually quite related)... but I digress.

What finalized jQuery as my framework of choice was the speed, ease, and simplicity of enhancing my webpages. I love the overloaded functions: a short list of methods with a long list of abilities. The required verbosity of YUI is a real turn-off for me. MooTools is better in many aspects and I appreciate its power, but if I’m writing a large-scale app I’ll be loading up with plugins anyway — at that point it’s simple to extend jQuery to MooTools’ native abilities. jQuery gets jobs done quick and clean, and is a breeze to add to old sites, as others have mentioned. Structure I can worry about later, if it’s worth the time — but for structure first, I can see how Aaron chooses MooTools.

P.S. jQuery plugins can be extended, their methods changed or overwritten, often to provide a default behavior… but you’re correct that true class behavior is not written into jQuery’s core.
Charles Phillips (URL) - 10 10 08 - 17:54

That was a great piece of information., I enjoyed reading it…DC hats
[url=http://www.popbrandcaps.com]DC hats[/url]
DC hats
[url=http://www.popbrandcaps.com DC hats]
DC hats (URL) - 11 03 11 - 00:58

That was a great piece of information., I enjoyed reading it…
red bull cap
[url=http://www.voguecaps.com/]red bull cap[/url]
red bull cap
[url=http://www.voguecaps.com/ red bull cap]
king - 06 05 11 - 01:16

That was a great piece of information., I enjoyed reading it…
monster hats
[url=http://www.voguecaps.com/]monster hats[/url]
monster hats
[url=http://www.voguecaps.com/ monster hats]
king - 30 05 11 - 02:27

diash hdiashid
daiod (URL) - 12 08 11 - 02:21


Trackback link:

Please enable javascript to generate a trackback url

  
Remember personal info?

Emoticons / Textile

Commentspam question
 

  (Register your username / Log in)

Notify:
Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.

 

Linkdump