Nate's Programming Blog

I am really getting into OO Javascript. I am really seeing the power, flexibility and maintainability potential that Javascript has. I’ve been working as a consultant/contractor at a company for about 9 months now and while there I have been building a Javascript library that I keep taking with me from project to project. The objects that I write are completely reusable and the dynamics of the language make the objects extremely flexible when I want to add functionality or extend functionality without modifying the code.

I’m getting into the habit of providing listeners on all my objects, that way when you want to do something after my object does something. You just call my addListener method on the object and provide it with the callback function(s)/object(s) you want to be called after a particular method executes. For instance, I have an Accordion object similar to the one on Rico, but mine allows for all elements to be closed. I have an addListener method that you can call and provide callback function(s)/object(s). I pass the Accordion object when I call your callback function(s)/object(s) and provide a state variable that you can check to see what the current state of the Accordion is. This was useful to me because in one example I needed to disable/enable input fields based on whether a certain element was in an expanded or contracted state.

Anyway, I’m hoping to eventually release my own open source library of javascript objects. I currently support an Accordion effect, a Fade effect, a vibration effect and table and list sorting functionality.

I also wrote an AJAX Command architecture that allows you to setup an hashset with a command parameter that you can map to a processor function/object. This allows you to configure what command gets called on the server and how to process the response and all you have to do is create the objects and call executeCommand on the AJAX command object. I also provide some backwards compatibility with older browsers. If you use the Command object is uses a Strategy pattern to decide whether to use the AJAX Command object or fallback to a Redirect Command object.

Anyway, I’m pretty excited about it all and hope I get more opportunities to increase my knowledge of OO Javascript.

Name (required)

Email (required)


XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Feel free to leave a comment