Today, for the first time, I used JavaScript in an object oriented way. I must say that I am impressed. The job called for a few parameters and some methods that all operated on the contents of a single div element, so an object to contain it all just made sense.

There are many great tutorials out there for getting started with JavaScript OOP. I’ve linked some of the ones that I used below. One thing to note is that JavaScript was not designed as an OO language so the syntax, you will notice, is very dirty looking. If you are used to C++ or Java you will just have to grin and bear it. JavaScript does, however, support all of the important OO concepts such as Encapsulation, Inheritance and Polymorphism.

In my code I made use of a concept called Singletons. Singletons are objects that are only created once since they are elements which shouldn’t be created multiple times. As an example think of a system scheduler, having multiple schedulers would just cause conflicts so you only want your one scheduler object created ever.

I’m starting to enjoy programming in JavaScript. It has made it possible to create some very simple but powerful user interfaces which otherwise would require a large number of page postbacks (server interaction).