What makes script.aculo.us and Prototype so darn special? I was using some of the facilities of Prototype, and came around to understanding that it was different somehow, but I couldn''t figure out how exactly. I was using static methods for a while, but when I wrapped my functions into and object the library suddenly started to do some serious lifting. The one big thing that''s different is the bindAsEventListener. It removes a big cross-browser issue, and it creates a "this" object that is truly useful. My question is this... Am I correct in saying that this is a major difference between Prototype and standard JavaScript, the ability to create a "Controller" object that can handle events using methods that act as if they were members the controller, rather than members of the target object. This creates a consistant environment across browers, and creates a meaningful this object that can maintain the state of the control. Correct? -- Alan Gutierrez - alan@engrm.com - http://engrm.com/blogometer/index.html - http://engrm.com/blogometer/rss.2.0.xml
Michael Schuerig
2005-Sep-28 08:29 UTC
[Rails-spinoffs] Re: script.aculo.us Design Patterns
On Wednesday 28 September 2005 08:02, Alan Gutierrez wrote:> What makes script.aculo.us and Prototype so darn special?[snip]> Am I correct in saying that this is a major difference between > Prototype and standard JavaScript, the ability to create a > "Controller" object that can handle events using methods that > act as if they were members the controller, rather than members > of the target object. This creates a consistant environment > across browers, and creates a meaningful this object that can > maintain the state of the control.I don''t really know what standard JavaScript is as I wasn''t using JavaScript in the old days. From some of the scripts I''ve seen in the wild it must have been (and still is) pretty bad. Prototype isn''t special in enabling the use of objects as event handlers. You can have the same with using closures explicitly[*] where Prototype hides them behind the scenes. However, closures are apparently something most programmers are not used to. What does make a difference, IMHO, is that Prototype is very well written and enables a programming style that is comfortable to programmers used to common object oriented languages. Also, it is easy to use and raises the level of abstraction of scripts considerably. Michael [*] http://jibbering.com/faq/faq_notes/closures.html -- Michael Schuerig They tell you that the darkness mailto:michael@schuerig.de Is a blessing in disguise http://www.schuerig.de/michael/ --Janis Ian, From Me To You