View Full Version : Reading and Understanding Source Code of ExtJS ( and ST)
6 Nov 2012, 9:41 AM
Lately, I started learning ExtJS. I've coded with ExtJS pretty far that I know how to use configs, methods and events.
But when I try to extend some component for my custom needs, I visit the source code and I get confused to be very honest. Not because of way of writing code, because of the content matter of code.
Can somebody please point me in right direction towards how to read source and understand it so that it could be easily customized to our own needs by extending it ?
6 Nov 2012, 12:03 PM
What makes ExtJS code so hard to read is the fact that it is so compartmentalized. When you go to look for something in a class it turns out that the actual code you are looking for is in a base class 4 levels deep or in a "mixin".
Great for code reuse, horrible for readability. I find it is easiest to find things from the documentation. For example, if I am looking at the doc for Panel, and I click on the "view source" for the setHeight method, it will take me to the source in AbstractComponent (5 levels below Panel), rather than me having to search my way down from panel manually. Of course that doesn't help when a class just sets a "property" that is used 5 levels deep but it's a start.
Other than that, it just takes time to get the feel of the code.
If you have any specific questions I'd (and probably plenty of others) would be happy to help.
7 Nov 2012, 1:04 AM
7 Nov 2012, 1:08 AM
http://docs.sencha.com/ext-js/4-1/#!/guide and read the part of the classsystem.
7 Nov 2012, 5:28 AM
I'd say more generally you shouldn't try to write an application in any programming language without making a proper effort to learn it. Even if you can avoid using advanced concepts in your own code you won't be able to avoid them in other people's code.
I agree with James Goddard that the docs app is the best place to read the source as it makes it much easier to jump around the class hierarchy.
7 Nov 2012, 5:39 AM
7 Nov 2012, 5:49 AM
Its just like learning to swim, just jump into the pool and don't drown.
11 Nov 2012, 2:06 AM
Thanks Guys for explaining it nicely :)
Can you point me to a sample extension of ExtJS ( a very simple one) so that I could try grasping some of that code and understand it for my own needs ?
Powered by vBulletin® Version 4.1.5 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.