I am an intermediate javaScript programmer, and i am interested in expanding my knowledge in object oriented programming (especially object oriented JavaScript).
I would prefer a book over browsing scattered web resources, does anyone have an idea of which book will be best to get a head start with?
Thanks
Object-Oriented JavaScript published by Packt was an invaluable resource for me recently when I was trying to learn JavaScript's prototype-based system without letting my traditional OO knowledge (Java, etc.) get in the way and make it more confusing.
For a slightly less in-depth treatment, I also recommend Pro JavaScript Design Patterns and John Resig's Pro JavaScript Techniques. Both have chapters on the topic.
It is important to distinguish between classic OOP and OO JavaScript.
While some languages such as Java, C# and Python are good for learning OO concepts such as classes, objects, inheritance and polymorphism - JavaScript is not one of those languages.
JavaScript can have object-oriented features but through the use of prototypes. It gets more complicated due to the complex data structures.
I think you should define exactly what you are looking after. If it's learning object-oriented concepts, you should go with a classic OO language to learn the basic concepts, and only then continue on to OOJS.
Refactoring: Improving the Design of Existing Code by Martin Fowler while the examples are given in Java, the principles behind it are applicable to most OO languages including JavaScript.
Definitely worth reading: JavaScript: The Good Parts by Douglas Crockford.
The chapter 5, "Inheritance" covers different types of Object Orientation:
- Pseudoclassical, simulating Class hierarchies by extending prototype objects with new methods
- Prototypal, without classes, using prototype objects to create new instances with common functionalities, then attaching new functions to these new objects directly
- Functional, using constructor functions to create a private scope and return a new object grouping a set of methods with privileged access to the private variables