Javascript is a powerful language but I can't get it why there are several ways to OOP, don't you think that it is adding a frontline barrier for new developers which have to work harder to master the libraries?
views:
112answers:
4JavaScript only does OOP one way: Prototype based.
Libraries like MooTools add layers on top of JavaScript to make it seem more familiar to people familiar with Inheritance based OOP.
If you're just starting out learning JavaScript, don't use a framework or library until you're familiar with the basics. That way you'll understand how everything really works instead of looking at different abstractions and thinking they're all native JavaScript.
Yes, you pretty much have to know OOP very well already if you want to do it in Javascript, it's not a good language for learning OOP.
Although you can implement most OO concepts, it's not what comes naturally for the language.
My puny prototype oriented mind cannot possibly comprehend the deep meaning of your question's title.
String.prototype.replaceBS = function() {
return this.replace(/principle|OO|OOP|enforce|static|class|private|protected|final|best practice|Java|IE/gi, 'lolcat');
};
(a = document.getElementById('question-header').getElementsByTagName('a')[0])
.textContent = a.textContent.replaceBS();
Ahhh...
The key phrase to focus on is "new developers". I would consider Javascript to be one of the more advanced languages even aside from OOP. The fact that you can redefine functions on the fly and add functions to core objects lead me to the opinion that new developers should probably stick to the entry level javascript stuff and get a hang for OOP in C++ or Java before attempting to create Javascript classes.
Also if you start creating a large number Javascript classes in your application it would probably be a good idea to take a step back and reevaluate your design and see if some of the logic should actually be done server side. I love AJAX, but sometimes it makes it easy to put too much logic on the client-side when in fact it belongs in the server code. This coming from a Javascript enthusiast.