JavaScript as an Application Platform
Background
The Internet as a development target has created entirely new architectural environments. The previously complex client/server arena has been all but replaced by ambiguous n-Tier designs—in which even the number of layers of software n must be defined through concerted design. Combine this with stateless connections, compressed project schedules, and a rapidly fluctuating business model, and it's easy to see why fundamental principals of software development often get left behind. In this article—through the practical example of UI component development—I attempt to demonstrate that not only are the basics of object-oriented programming still important, but JavaScript is capable of implementing enough of them to create credible Web applications.
Typical Web application design rests on the user requesting pages for nearly every interaction. This arrangement—even with a broadband connection—is slow, resource intensive, and unacceptable in any other software environment. By creating even basic user-interface components, which are standards in other GUI development, the possibilities unfold very quickly for powerful applications to be created. For the context of this article, I'll demonstrate the inner workings of a JavaScript function object that behaves as a tab panel.
A tab panel makes a good example, considering the fact that many search engines that sort results provide "fake" tab panels already. (Wouldn't it be nice if you could change between types of hits returned freely without requesting a new page?) As a cursory review, the important elements of OOD (object-oriented development) include encapsulation of functionality, code reuse, and event-based program flow. (I don't need to hear about polymorphism and inheritance; I know they exist, but they're less important when you have to rely on the functionality of another application—in this case, a browser, or even two—for the heart of everything you attempt, especially when the language doesn't even compile yet.)