Re: Issue 66 in canviz: Don't require Prototype

7 views
Skip to first unread message

can...@googlecode.com

unread,
Jun 13, 2011, 3:44:50 AM6/13/11
to canviz...@googlegroups.com
Updates:
Summary: Don't require Prototype
Labels: -Type-Defect Type-Enhancement

Comment #1 on issue 66 by ryandesi...@gmail.com: Don't require Prototype
http://code.google.com/p/canviz/issues/detail?id=66

I have no particular loyalty to Prototype; it was just the framework I
happened to have already learned at the time I was developing Canviz. If I
switch Canviz from Prototype to jQuery, that might make you happy, but
displease those already using Canviz with Prototype. And there may be
others wanting to use MooTools or another framework.

For maximum interoperability, I would like for Canviz to not require any
JavaScript framework, but I'm not sure how best to do that. There are
features Canviz uses which aren't built into JavaScript. For example,
Canviz uses Prototype's class-based object inheritance model; this fit more
easily into my brain than JavaScript's default prototype-based object
model. Also, I want to dynamically load additional JavaScript files as
needed (see issue #20), and I assume that Prototype and other frameworks
offer a function to do that, and that it would be tedious to do manually.
Canviz already uses other Prototype conveniences which are tedious to do
manually, but in the interest of decreasing framework dependence, I'm
willing to forgo those conveniences, if they can be replicated without
bloating the code too much.

Any work on reducing Canviz's framework dependence should also consider the
Path library, which Canviz uses. There was a patch submitted to remove the
Prototype dependency from Path, in response to this discussion thread:
http://groups.google.com/group/canviz/browse_thread/thread/ae7ff77d60825bf3/6974cc25e2255948
The patch was submitted to me privately by Frank Hess, but I will attach it
to this ticket now. I did not apply it at the time because it made many
different changes at once, and was hundreds of lines long, making it hard
for me to review. He said:

"I made the following changes:
"- Classes created using closures where possible
"- changed Object.isUndefined() -> ===undefined
"- changed the prototype each constructs to for loops

"There is only one function call I'm unsure: In line 42 (this.reset();) - I
commented it out."

So the reset issue needs to be addressed, and the patch needs to be
evaluated by someone who has a thorough understanding of both class-based
and prototype-based object models who can determine if Canviz still works
the way I programmed it to after these changes. I would also want each
logical change committed separately: for example, all instances of
changing "Object.isUndefined()" to "=== undefined" would be one commit,
changing all Prototype "each" constructs to "for" loops would be a second
commit, and so on.

How do other JavaScript libraries deal with this problem? Do they offer a
choice of frameworks (if so, how do they accomplish that?) or do they just
write everything themselves?

Attachments:
path.js.diff 18.6 KB

Reply all
Reply to author
Forward
0 new messages