THE PASZ.COM BLOG

Saturday, July 16, 2005

A Practical Approach for Implementing Inheritance in JavaScript

Just getting the blog going here today with a few posts. Here's an article I wrote a while back about inheritance in JavaScript. After doing a lot of reading on this topic, I tried to boil things down in a way that's practical and useful. But certainly my ideas could use some feedback and refinement.

Here are the basic strategies I recommend when building Classes in JavaScript:
1. Keep your class hierarchies shallow
2. Don't rely on calling superclass constructors or methods. Instead just give them different names.
3. Use polymorphism to your advantage, but don't overuse it.
4. Keep code organized and well-commented to help explain how your classes are arranged.

more...

2 Comments:

Post a Comment

<< Home