Object-Oriented Javascript by Stoyan Stefanov: a book review
My friend and collegue Stoyan Stefanov recently asked me if I wanted to write a review of his new book on Object-Oriented Javascript. Of course I agreed and took some time to read the book and form an honest opinion about it. What follows is a review of this new recently released book.
Object-Oriented Javascript is a pure javascript book. It's quite a bit different from many books I've seen before and in this case this is a good thing.
First chapters
In the first two chapters Stoyan provides a quick crash course on the history of Javascript, some fundamentals of OOP (Object-Oriented Programming) and language fundamentals. The first difference with a lot of other books shows fairly early in the book. Stoyan invites his readers to use the FireBug console and immediately try out the examples given in the book to experience them first-handed. The examples are never long winded or complicated but come straight to the point. A great way to achieve an instant learning effect!
Functions
The third chapter deals with functions. The author will take you knee deep into all aspects of Javascript functions, not avoiding the tricky parts such as self-invoking function, inner functions and closure. Stoyan succesfully manages to explain the fairly difficult to grasp concept of closure in a clear, easy to understand way. A remarkable accomplishment!
Objects
Chapter four deals with Javascript objects. Since everything in Javascript is an object there's quite a lot to tell about this subject. Like in all chapters of the book, everything is explained by using very small and simple examples which can be typed directly into FireBug.
Prototype
Prototype is yet another concept which can be hard to grasp for newer Javascript programmers. This definitely includes people who come from a classic OOP background. I suppose there's a risk of this review becoming a bit boring but again, Stoyan hits the spot with his examples and crystal clear explanation.
Inheritance
The chapter about Inheritance is probably the most impressive part of this book. Stoyan manages to clearly demonstrate no less than twelve different ways to approach inheritance in Javascript and finally presents these in a compact easy to understand overview. The chapter concludes with a case study example which is unlike most of the other examples a bit more lenghty but still small enough to not be intimidating to any reader. Even seasoned Javascript programmers may still learn some interesting bits from this chapter.
Browser Environment
In the seventh chapter, Stoyan discusses the browser environment, working with the DOM and a bit of AJAX. As we all know, whole books that are significantly heftier than this book have been written on this subject so don't expect to become a DOM guru after reading this chapter. Still however it provides a nice overview of both the browser environment and common DOM methods. As this chapter only briefly touches most of the subject matter, a lot of readers could probably do with another book specifically about DOM scripting and AJAX. Christian Heilmann has a great title on this subject.
Coding and Design Patterns
The last chapter of the book is an excellent primer on best practice coding patterns and some common Javascript design patterns. It talks about subjects like separating behavior from content and presentation, namespacing, use of configuration objects, chaining and use of JSON. Finally some popular patterns such as the Singleton, Factory and Observer are discussed and examples are given on how to implement these patterns in Javascript.
The verdict
First things first, Object-Oriented Javascript is a really good book with a refreshing approach on learning a language. What it does NOT provide is fancy code snippets that are ready to (ab)use in any website. This is a real book about programming and not about impressing your friends with some fancy website features. The book is completely neutral on javascript frameworks which is a popular topic in fanboy battles. In some cases it briefly mentions frameworks but only to demonstrate that certain practices are used in them. Therefore, another thing you won't learn from this book is how to do crazy stuff in JQuery, YUI or another popular framework you may like.
This book is about javascript and javascript only. For anyone who is serious about his/her javascript skills I feel this book is a must read. This book is truly one of a kind. Even the more experienced developer will find quite a few interesting techniques in this book which makes it suitable for both intermediate and more experienced programmers. I'm not sure how well this book is suitable for total newbies but if you're smart this book will give you a truly 'head first' introduction to javascript. Object-Oriented Javascript will make almost anyone a better javascript developer. And let's face it, a book that's able to explain closures in a way that most readers will actually understand what it means without being horribly confused is an instant winner!
A highly recommended read!
Tags: programming, javascript
Filed under: programming
Number of comments:
Number of trackbacks:
Tagged with: 







At 22 August '08 - 01:42 Stoyan wrote:
Just want to add for everyone interested in checking out the book that the second chapter is available as a PDF download.
At 22 August '08 - 02:04 Stoyan wrote:
http://www.packtpub.com/files/Object-Ori..
At 01 September '08 - 22:45 Oto Meskhy wrote:
I Wont Miss A Chance And Tell You That This Book Is Brilliant! I Just Got It Last Week And I Read It In 4 Days :) Im Not JS Guru Or Beginner, But This Book Really Does Provide Everything That You Need To Know! ;) Thanks!
@ Macro:
Very Good Review, You Just Got The Point! Thanks.
At 11 September '08 - 17:18 Bombchell -in atlanta wrote: