Sunday, April 26, 2015

OOJS Tutorial Notes

Last week, I would have told you that Class.js was feature complete. In fact, I think I said something like that in the first paragraph of the tutorial pages. And once again, I've proven myself wrong. Some days it seems like I'm my own worst enemy. So what did I miss?

For those of you familiar with OO programming, do you remember that feature where from in a class method, you can access the private scope of other instances of the same class? That's the thing I forgot! In the case of Class.js, that proves to be a problem. I found myself blindly trying to use that feature of classes just to get told off by the JS interpreter since the public interface of the sibling object obviously didn't contain the function I was trying to call.

I've got the solution, though. It's not as straight forward as what you get in OO languages, but it achieves the same effect. At the same time, it's dangerous. I'm not sure if I want to keep the feature or not in it's current invocation. In either case, you'll learn about it in part 3 of the tutorial.

No comments:

Post a Comment