JavaScript: the Good Parts

JavaScript: the Good Parts

JavaScript: The Good Parts
by Douglas Crockford, Dec 2008, 978-0596517748

It is interesting that I never really picked up JavaScript seriously before, though it has been the language of the web for over 10 years. By serious, I mean of course I have produced a few code snippets in it, but I’ve never even bothered to actually learn the syntax. You know, most people write JavaScript just like this, cut-n-past, trial-n-error. The perception of the language for most people is quite lame. Well, it turns out not to be lame at all.

This book to JavaScript is very much like Martine Fowler’s book to UML. I liked UML Distilled so much. I prefer the approach of learning by the best yet small parts first, at least as a start. Not only the learning curve is made more appealing, but those not-so-useful parts are avoided if we don’t ever use them. Why bother if I never used diagrams other than class, activity, or sequence diagrams in UML? Wouldn’t it be great to just learn how to use those 3 diagrams?

In this book, Crockford talks about JavaScript only. No DOM, no browser, pure JavaScript, simply the language itself. He also only focuses on a subset of JavaScript. He calls this subset “good parts”, which is a selected set of constructs and concepts in the language he considers good for programming. So what are the good parts of JavaScript?

  1. loose typing
  2. expressive object literals
  3. functions
  4. prototypal inheritance

Personally I think the most important concepts to grasp in JavaScript is the prototypal inheritance and functions. Chapter 3 has a great introduction to JavaScript’s object model and how prototype works. Chapter 4 introduces functions, including the function scope, closure, and the 4 kinds of function invocation pattern. The usage of constructor is also introduced in this chapter to let you understand what the following code snippet does and how it works:

var Quo = function (string) { this.status = string;};
Quo.prototype.get_status = function ( ) { return this.status;};

var myQuo = new Quo("confused");
document.writeln(myQuo.get_status( ));

Understanding this is vital to either pseudo-classical or prototypal inheritance, which are introduced in chapter 5. Crockford considers pseudo-classical inheritance as a “bad” part of the language and advocates the usage of prototypal inheritance or even functional style instead.

These 3 chapters are probably the most important ones in the book (chapters 3, 4, and 5). The rest mostly introduces various parts of the languages by mentioning what should be noted when using them. The style is more like “gotchas”. In the appendices, Crockford also lists the awful and bad parts of the language he thinks you should be aware of (the awful parts) and avoid (the bad parts).

This book is very good in helping understand the core parts of JavaScript. Though the book is recommended by most people, its intention (using only “good” parts of the language) is rather controversial. For example, some don’t agree that pseudo-classical inheritance as bad part, but some agree that given 2 ways of doing the same things, why choosing the confusing one. Nevertheless, it’s always a good thing to know the opposite sides before you make your mind.

I do have a slight complaint about the book. Some places are inconsistent across the whole book. For example, Crockford has provided a very useful method for creating objects with the ability to designate their prototype objects (so you don’t need fiddle with the use of “new” operator). However, most of the time he calls this method “Object.prototype.beget” in the book but in the provided source code it was named “Object.create” (which is quite confusing, isn’t it?). Checking from his Prototypal Inheritance in JavaScript, it’s obvious that many places mentioning “Object.prototype.beget” was not updated accordingly while introducing the improved version of that method into the book. The same problem also exists in the way he introduces to identify array object type, which is inconsistent between chapter 6 and appendix A.

Another one I found rather annoying is that his terse explanation is sometimes, well, too terse. For example, while mentioning the wrapping of JSON text from the wire in parentheses, he simply explains:

The concatenation of the parentheses around the JSON text is a workaround for an ambiguity in JavaScript’s grammar.

which was too terse in my opinion.

Overall I really like this book. It’s light but deep, and yet easy to grasp.

Harry Potter and the Deathly Hallows

Harry Potter and the Deathly Hallows

The sequels are getting longer and longer and finally there comes the finale. I really can’t wait longer ... I definitely will get one on the very first days when it gets to the market.

Oh! This time remember not to read any news from July 21th until you finish reading it. Last year it was too late when I realized I knew the ending before I even got the book. I just can’t get why people would like to know who gets killed and what the ending is on the very first day the book is published (from newspaper!!). Sham on you whoever wrote that on paper!

PMP

Have you heard of PMP? Probably you have, I guess.

My feeling about PMP (or any other certificate) has always been somewhat in line with Scott Berkun: License to manage?. Certificates are nice to have, but not requirements.

Most certificates today have specialized learning guide for you to quickly grasp everything you need to get those certificates. I do admit the acquiring a certificate itself does add some value in learning a topic. It gives you a goal and some study area (most of the time with a truly excellent study guide). I do tend to acquire certificates as bonus for learning a new topic (if I don’t need to pay for them). It might not be useful, but certainly not harmful.

Well, PMP is by far the most painful one I’ve ever tried (and probably the most valuable one). Naturally there’s an excellent study guide for it:

PMP Exam Prep, Fifth Edition: Rita’s Course in a Book for Passing the PMP Exam
by Rita Mulcahy

I would say the book itself (along with its simulation software) should be enough for you to pass the exam. I have read it thoroughly for 3 times and have done 4 simulations (all with scores much higher than the passing criteria).

BTW, I did take several project management courses during the last few years. So my experience might not be a perfect match for you.

Waltzing with Bears

Waltzing with Bears - Managing Risk on Software Projects
Waltzing with Bears - Managing Risk on Software Projects
by Tom Demarco & Timothy Lister

The business of believing only what you have a right to believe is called risk management. Say you have a schedule set for the project and you believe that it is reasonable. But do you have the right to believe that? You can’t just say “yeah, I believe I can do it!” and just hope the result will be what you want. You have to do you best to make sure that what you want will be the result. That’s “risk management”.

If a project has no risks, don’t do it. If you do it, you have to manage the risks of it. There are 4 main tasks in risk management:

  • Create a risk list and assess the risks on it. You have to determine the impact and probability of the risk materialization, its exposure, contingency and mitigation actions for it. Keep refining the list should be a continuing part of the project.
  • Create risk diagrams to express the uncertainty. This book provides a tool for doing that.
  • Create an incremental delivery plan and an earned value running diagram. This is used to track the progress of the project.
  • Monitor all risks for materialization or expiration and EVR diagram for any deviation.

This book provides detailed steps in risk management. It tells you what you should do but not how to do it. To learn how, you have to practice in your projects.

A Whack on the Side of the Head

A Whack on the Side of the Head
A Whack on the Side of the Head: How You Can Be More Creative
by Roger von Oech

This book teaches how to be more creative by telling what are the reasons caused us being uncreative. It lists ten mental locks, which are our own attitudes got in the way when we need to be creative.

  1. The Right Answer
  2. That’s Not Logical
  3. Follow the Rules
  4. Be Practical
  5. Play Is Frivolous
  6. That’s Not My Area
  7. Don’t Be Foolish
  8. Avoid Ambiguity
  9. To Err Is Wrong
  10. I’m Not Creative

The approach taken by the author does not provide any specific magic of how to have creative mind. However, it shows some answers to why we are not creative enough. By reading it, we could exam our own thinking process and try to be more creative by unlocking our mental locks.

It’s a light book with many great points that can really whack your mind.

Automatic Testing

Pragmatic Project Automation
Pragmatic Unit Testing in Java with JUnit

by Andy Hunt, Dave Thomas

If you have not yet been a fan of JUnit, you need this book. This book provides a tutorial and is extremely well written. This book also provides a systematic structure for writing unit tests. It could be valuable for those who have been writing unit tests for a while but need a guide along the way to write better test code.

Automatic Project

Pragmatic Project Automation
Pragmatic Project Automation: How to Build, Deploy, and Monitor JavaApps

by Mike Clark

I really like this book. It is small and very easy to read. The very fundamental idea is to absolutely automate everything so that we human beings won’t have any chance to have an excuse. The idea is not totally new, but it does make me try to find every possibility of automation.