Code review comment for lp:~bcsaller/juju-gui/namespace-routing

Revision history for this message
Gary Poster (gary) wrote :

I only got halfway through routing.js, but wanted to share what I had
before I went into calls. No one should wait for me: please don't count
me for the two reviews today. However, I will return to this if I can.

Gary

https://codereview.appspot.com/7327045/diff/3001/app/assets/javascripts/routing.js
File app/assets/javascripts/routing.js (right):

https://codereview.appspot.com/7327045/diff/3001/app/assets/javascripts/routing.js#newcode5
app/assets/javascripts/routing.js:5: // particuallary around text
copy and paste error: please update comment to describe what this
actually does (and the old comment has a typo, "particularly," but the
associated module has been removed from trunk).

https://codereview.appspot.com/7327045/diff/3001/app/assets/javascripts/routing.js#newcode7
app/assets/javascripts/routing.js:7: function _trim(s, char, leading,
trailing) {
I don't understand yet why this only trims a single character. My
suspicion is that, as I read, I'll understand that this is all you need,
and otherwise you would have been in the "oh my gosh JS doesn't have a
built-in regex excape function" place.

https://codereview.appspot.com/7327045/diff/3001/app/assets/javascripts/routing.js#newcode20
app/assets/javascripts/routing.js:20: function ltrim(s, char) { return
_trim(s, char, true, false); }
Wouldn't it be nice if the built-in trim were flexible enough for what
you need!

https://codereview.appspot.com/7327045/diff/3001/app/assets/javascripts/routing.js#newcode23
app/assets/javascripts/routing.js:23: function pairs(o) {
docstring would help with easy reading.

Return sorted array of object attribute pairs (name, value).

https://codereview.appspot.com/7327045/diff/3001/app/assets/javascripts/routing.js#newcode37
app/assets/javascripts/routing.js:37: // Multi dimensional router
(TARDIS).
lol

https://codereview.appspot.com/7327045/diff/3001/app/assets/javascripts/routing.js#newcode49
app/assets/javascripts/routing.js:49: return parts[0];
trivial, but when placed next to your getQS implementation, "return
url.split('?')[0];" looks pretty reasonable.

https://codereview.appspot.com/7327045/diff/3001/app/assets/javascripts/routing.js#newcode65
app/assets/javascripts/routing.js:65: var parts =
url.split(this.fragment);
Might be helpful to include examples in comments:

> '/foo/bar'.split(/\/?(:\w+\:)/)
["/foo/bar"]
'/> :baz:/foo/bar'.split(/\/?(:\w+\:)/)
["", ":baz:", "/foo/bar"]

https://codereview.appspot.com/7327045/diff/3001/app/assets/javascripts/routing.js#newcode67
app/assets/javascripts/routing.js:67: // This is a URL fragment w/o a
namespace
Took me a second to agree, but yes, nice.

https://codereview.appspot.com/7327045/diff/3001/app/assets/javascripts/routing.js#newcode68
app/assets/javascripts/routing.js:68: result.charmstore = parts[0];
wait a second, that's not general-purpose! :-)

I don't see the need for this to be general purpose. I suggest moving
it into app/routing.js. Alternatively, if you really want to, clean
this up.

https://codereview.appspot.com/7327045/

« Back to merge proposal