[Sugar-devel] [Karma] questions about jquery.karma.js

Bryan Berry bryan at olenepal.org
Tue Nov 3 23:31:15 EST 2009


I am refactoring jquery.karma.js using test-driven development.

I think you did a great job in writing it in the first place, but I am
far to lazy to manually test out the entire library every time I make a
change.

Reading through jquery.karma.js, I have some questions:

--- the init function ---
You have an init function that receives the assets to be loaded as an
argument but actually loading them happens in the first part of the if
statement of karma.main . To me it would make more sense to just pass
the assets as an argument to karma.main({ /* assets object */}) and not
the function call back as currently. 

Ideally I would like the use of Karma in lesson.js to be as simple as

var k = Karma({ images: [ .....], sounds : [...], surfaces : [....]})

// the rest of the code for a lesson

I don't understand the if statement in karma.main. It seems to me that
the callback to main function would never be called. That the first if
clause will always be true and karma.main() won't be called a second
time.

--- taking out the jquery inside Karma ---

I like how we have packaged  karma as a jquery library because it gives
us a standard pattern to follow. That said, I don't want to use jquery
internally to the library so dojo or prototype fans can use it freely

--- to prototype or not to prototype? ----

I intend to use monkey-patch the Object object with the function create

so Object.prototype.create = function ...

this create function will be implemented in Ecmascript 5 and it matches
Crockford's object(o) function for prototypal inheritance. This is my
excuse for monkey patching ;)

-- KButton ----

What is the purpose of KButton?


--- mouse.getRelativeCanvasPosition, handleEvents ---

do you have any code that uses these functions so I can see an example
of them in action?



those are the main questions I have for now. Thanks for reading this far
in a long e-mail ;)

I know you are very busy with your exams right now, but do u think we
could chat in the next couple days for about an hour about the structure
of jquery.karma.js?

I am on the east coast of the US right now so timezones are easier :)

-- 
Bryan W. Berry
Senior Engineer
OLE Nepal, http://www.olenepal.org



More information about the Sugar-devel mailing list