Bounty Edit:
I’m looking for code written in a pure prototypical OO paradigm (think Self). Not a mixture of prototypical OO and classical OO. I don’t want to see generic OO wrappers but simply usage of prototypical OO techniques and only prototypical OO techniques.
Reference Related Question:
In the above question I mainly focused on
Can write prototypical OO like this?
Do we need constructors and initialization logic, What are the alternatives?
New question:
Basically are there any good examples of javascript prototypical OO in large open source projects?
Clarification:
I will have to clarify what I mean with prototypical OO :
- There are no classes. There are only Objects.
- There is zero emulation of the concepts of classes, again there is only objects and cloning objects to create new objects.
Further Clarification of Prototypical OO:
The difference between prototypical OO in JavaScript and classical OO emulation is a very grey area. It’s not that I value avoiding classical OO. I want to learn prototypical OO in an academic fashion in it’s own right, without learning the (probably more optimum) combination of classical OO emulation and prototypical OO.
This is why I “ban” classes, just so that I can see these techniques in a pure fashion and extend my own OO tool kit.
Examples:
Popular examples like jQuery fail to meet the second criteria. The jQuery object is one big class emulation. It focuses on creating new objects from a class rather then cloning existing objects.
If I actually knew any example of using “pure” prototypical OO I would have shown you. I believe 99% of JavaScript OO is too heavily influenced by classical emulation.
Bonus points
If
- It’s well comented / documented
- Has unit tests
- Is on github.
I will also accept articles / tutorials and examples on how to write prototypical OO code that goes beyond your trivial hello world application.
You will not find it.
I went looking for this sort of thing a while ago, and this is what I found: the Self Paper Organizing Programs Without Classes (Look at Citeseer for a PDF version.) This paper discusses the best practices for Self, the original prototypal language, and the best practice is to use the “traits object idiom”, which is to have your objects inherit from “traits objects” that contain only methods, and no object specific data. In other words, an object that is suspiciously like a class.
Even the original prototypal language emulates classes.