What is Object Oriented Programming? Why use Object Oriented Programming? How does Object Oriented Programming apply to JavaScript? Those are the questions I am going to try and answer for you.
What is Object Oriented Programming?
Object Oriented ProgrammingW (OOP) in the simplest of forms is grouping all of the data and functions that operate on a particular thing together. An example might help. Suppose you were told to build a banner that changed content at regular intervals and the content for the banner was to be retrieved from an http URL. We know we are going to need a variable to hold the change interval for the banner. We will probably need a variable to hold the URL that we get the banner content from. We might need a function to send the request for the new banner data. We might need a function to render (display) the new banner data. And of course we need some sort of way to control it.
Now we know all of the parts that are required to build the dynamic banner. So now lets design our object. Read more…
Object Oriented Javascript (OOP) Part 2
I would like to build on the Object Oriented Javascript page I talked about in an earlier post. I explained how to use inheritance and polymorphism but sometimes a static function ( that is there is only one copy of the function no matter how many objects you create) can be real handy for utility functions.
If you recall the class hierarchy before Shape was the base class and Circle, Square, Triangle were subclasses well now lets add some static functions to the Shape class. This example might be a little bit of a stretch but it will illustrate my point.
Read more…
Do you know what contributes to slow page loading? First of all it is the total size of all your scripts, css, and wireframe (html). After that the number or connections that you make to the server to load the data. There is 1 connection for each script, 1 for each css file, 1 for each image in your html, and 1 for each ajax request you make. Most browsers allow about 8 simultaneous connections. If you use more than 8 the extra connections have to wait for one of the eight to finish and then they start.
Read more…
Do you think that adding Drag-n-Drop capabilites to your website is a huge amount of work? What if I told you it was a piece of cake? Check out this example showing how easy it realy is. Dnd Drag-n-Drop Javascript simplified.
Google is now hosting the following javascript libraries with more to come.
- jQuery
- jQuery UI
- prototype
- script_aculo_us
- MooTools
- dojo
Have you ever wondered if there was a way to write javascript that looks almost like Java? Well, there is thanks to the guys that wrote prototype. I wrote up an example to help get you started “Object Oriented Javascript”.
Here at JustJs.org we aim to provide you wealth of javascript widgets, scripts, and snippets.