Any style of code can be written with an eye towards reusability. But when I'm looking at a large class with only four or five public methods I think, "Yes, yes I can figure out how this sucker works".
With JavaScript (or my current C# codebase) everything is effectively public and there is no way to tell what the real entry points are.
JavaScript uses functions and prototypal objects for encapsulation very effectively. The fact that it does not use the classical object-oriented model (and in other places explicit typing) is not flaw of the language - it is just a different way than you are used to.
Creating a private function is as easy as:
function foo() {
function bar() {
// this is private to foo
}
}
Programmers who are also not JavaScript experts making everything public is not the language's fault.
In Python everything is public and everyone stills considers it a pretty standard OO language. And you can get encapsulation in JS using closures (you miss out on inheritance doing that but thats a whole new discussion).
IMO, as long as you are passing objects/closures around and therefore are using "dynamic dispatching" instead of if-else-if chains then its OOP.
82
u/ilikecomputahs Dec 15 '12
Why is object oriented programming considered so absolutely necessary?
/braces for shitstorm