My post about learning to organize classes without the semantic sugar of Prototype earned me some wide-ranging comments here and on Ajaxian. My favorite was
Let's face it, in the wide world of web development, for every
"real" object-oriented language. Programmers with a broad range of
loose typing, dynamic nature and prototype-based inheritance scheme are
actually far more "object-oriented" than, say, Java or C++. That may be
true, but there are lots of folks out there writing production code who
have never written complex software using any language _but_
both a blessing and a curse. There's a lot of freedom, but not a lot of
guidance. Languages that rely on good developer
behavior rather than the intrisic properties of the language themselves
A note on this list: It's a highly subjective smattering of articles I found useful. Some are high-level discussions of JS itself, or of inheritence strategies in general. Others grapple with the interitance models of specific libraries in ways that highlight the underlying issues. I could post a completely separate list of JS/Ajax frameworks and their various approaches to the topic. But that's a different post for a different day.
On to the list:
- OOP in JS: An older but still-relevant multi-part case study in how to mimic class-based inheritance in JS.
- Prototype: Inheritance Madness: An examination of Prototype's approach to classes.
Closures, the Global Namespace and the Module Pattern
- Global Domination: A seminal YUI blog post about the dangers of the global namespace.
- YUI's Module Pattern vs. Prototype's Class Function: Isaac Z. Schlueter's interesting post on Crockford's module pattern and how to extend it into a reusable constructor.
- Show love to the Module Pattern: More commentary on the module pattern.
Singletons, Lazy Constructors and Memoization
- Lazy Function Definition Pattern: A blog entry from a functional-programming viewpoint.
Further Reading: DSLs, Aspect-Oriented Programming and More
- AspectJS: An AOP library for crosscutting concerns.