5
votes

In the course of programming we encounter large javascript files which are open source and written in an object oriented manner( like JQuery ).

If we need to modify these files we have to have a basic knowledge of the members and the flow. If we have multiple files then the task is much more difficult.

Where do I start to get the flow of this??

5

5 Answers

12
votes

First of all I think that you have to understand how JavaScript object orientation works, JavaScript OO is Prototype-based, in which classes are not present, and behavior reuse is implemented by prototyping.

I've seen that this can be hard to catch at the beginning for programmers that have been working on conventional class-based object-oriented languages (like C++, C#, Java, etc).

Recommended articles:

3
votes

There are two things I would do:

  1. Read. If there's documentation files, read those. If there's comments, read those. If neither of those help you, then go to the source and read that.

  2. When you talk about open source Javascript, I assume you mean this JS is collected into some kind of project; all client-side JS is open source :P. In that case, the authors may be willing to tell you about their code. Locate their email on the project page, and ask them to give you a high-level overview of the code so you can start reading it and understanding it yourself. They probably won't be willing to hold your hand through the entire thing, but having that as a starting point would probably help.

1
votes

I have a copy of

and

sitting on my desk right now. Incidentally these are the only two Javascript books which Douglas Crockford thinks are any good ;)

They'll teach you how Javascript works, specifically how its object model is different to most (but not all) other object-oriented languages.

Other than that, do check out all the articles on Crockford's website, as have already been mentioned in other answers.

0
votes

I agree with allyourcode there's no magic trick. You have to read the code and read the docs. And if the docs are no good, maybe you should think about using a different framework.

0
votes

A good start is in understanding the difference between traditional OO and Javascript's Prototype model. (Crockford has some articless that implement traditional OO for Javascript in order to contrast the behaviors.)