Object Oriented Javascript Techniques
"Recently I interviewed a software developer with five years experience
in developing Web applications. She’d been doing JavaScript for four
and a half years, she rated her JavaScript skill as very good, and—as I
found out soon after—she actually knew very little about JavaScript. I
didn’t really blame her for that, though. JavaScript is funny that way.
It’s the language a lot of people (including myself, until recently!)
assume they’re good at, just because they know C/C++/C# or they have
some prior programming experience.In
a way, that assumption is not entirely groundless. It is easy to do
simple things with JavaScript. The barrier to entry is very low; the
language is forgiving and doesn’t require you to know a lot of things
before you can start coding in it. Even a non-programmer can probably
pick it up and write some useful scripts for a homepage in a matter of
hours.
Indeed, until recently, I’d always been able to get by with whatever little JavaScript I knew, armed only with the MSDN®
DHTML reference and my C++/C# experience. It was only when I started
working on real-world AJAX applications that I realized how inadequate
my JavaScript actually was. The complexity and interactivity of this
new generation of Web applications requires a totally different
approach to writing JavaScript code. These are serious JavaScript
applications! The way we’ve been writing our throwaway scripts simply
doesn’t cut it anymore.
Object-oriented
programming (OOP) is one popular approach that’s used in many
JavaScript libraries to make a codebase more manageable and
maintainable. JavaScript supports OOP, but it does so in a very
different manner from the way popular Microsoft® .NET Framework compliant languages like C++, C#, or Visual Basic®
do it, so developers who have been working extensively with those
languages may find doing OOP in JavaScript strange and
counter-intuitive at first. I wrote this article to discuss in depth
how the JavaScript language really supports object-oriented programming
and how you can use this support to do object-oriented development
effectively in JavaScript. Let’s start by talking about (what else?)
objects."
Check that out here