Tuesday, September 19th, 2006

Objectifying JavaScript

Category: JavaScript, Programming

<>p> Javascript is just like any other language – well, sorta. It has the power to make your web applications really earn their keep and perform for the user. It also can be confusing if things start getting pretty complex. Thankfully, there’s something that can help you compartmentalize your code and make it simpler to use more modularly – the object oriented functionality Javascript offers. Don’t know how to get started with it? Well, check out this new article over on Digital Web Magazine for a few tips.

As scripts get larger, functions become more interrelated. Suddenly, you’ve got ten functions on a page, six of them calling each other to accomplish one task, and another four working towards something else entirely. For someone taking a first look at this code, it certainly wouldn’t be immediately clear which were meant to work together and which weren’t. This is where objects come in.

The author, Jonathan Snook, gets down to the basics of objects in Javascript – what they are, how to create them, how to access them, and much more. If you’ve ever done any work with the popular libraries like Prototype or Script.aculo.us, some of this will look familiar. He even gets into design patterns in OOP for Javascript with setting up Singletons and Factory patterns.

Posted by Chris Cornutt at 10:20 am
2 Comments

+++--
3.4 rating from 25 votes

2 Comments »

Comments feed TrackBack URI

Interesting Finds: September 19, 2006

Trackback by Jason Haley — September 19, 2006

One more advanced JavaScript class is presented in the following webpage. It is easy to read and understandable format but bit large. It shows Airplane component. It uses a novel encapsulation of GUI component code.
http://www.cbsdf.com/technologies/GUI-Class3.htm
http://www.cbsdf.com/technologies/airplane.htm

You need Internet Explorer and Adobe’s SVG Viewer to see the GUI component in action (e.g. to see how it flies). This shows, how to draw a GUI Component and embed JavaScript code to make it interactive. Also contains Ajax code to communicate with server to update the component.

If you need a simple JavaScript-Class and SVG example:
http://www.cbsdf.com/technologies/include-the-SVG-Component.htm

Comment by Raman — September 20, 2006

Leave a comment

You must be logged in to post a comment.