fluid-tech IRC Logs-2012-11-13
[19:17:45 CST(-0600)] <kasper> https://github.com/kaspermarkus/universal/blob/GPII-32-2/gpii/node_modules/settingsHandlers/src/js/XMLSettingsHandler.js#L53-85
[19:17:54 CST(-0600)] <kasper> Bosmon ^
[19:18:45 CST(-0600)] <Bosmon> KASPAR
[19:18:50 CST(-0600)] <kasper> along with this test: https://github.com/kaspermarkus/universal/blob/GPII-32-2/gpii/node_modules/settingsHandlers/test/XMLSettingsHandlerTests.js#L27-62
[19:19:15 CST(-0600)] <kasper> uh-oh .. it's always hard to tell whether capitals from you equals yelling or just regular naming
[19:19:25 CST(-0600)] <Bosmon> hahaha
[19:19:54 CST(-0600)] <kasper> So I guess my first question is; does what I'm doing look at least relatively sane?
[19:19:57 CST(-0600)] <Bosmon> Looking generally reasonable as first draft
[19:20:08 CST(-0600)] <kasper> cool
[19:20:17 CST(-0600)] <Bosmon> We can take care of some early points of style:
[19:20:21 CST(-0600)] <kasper> sure
[19:20:31 CST(-0600)] <Bosmon> i) Assing expandSpect.options.key to a suitable local variable to avoid constantly referencing it
[19:20:45 CST(-0600)] <Bosmon> ii) rewrite the loop in terms of a fluid.each to avoid the unpleasantly named variable "tmp" : P
[19:21:13 CST(-0600)] <Bosmon> iii) The "delete" at line 76 is probably hazardous - I believe it is the mission of the transformer not to modify its arguments
[19:22:14 CST(-0600)] <kasper> yes - (iii) was pure laziness on my part .. sorry
[19:22:53 CST(-0600)] <Bosmon> Your "missing" check should probably be replaced with a check that the key has the appropriate type
[19:23:16 CST(-0600)] <kasper> ah, yes, that makes sense
[19:23:21 CST(-0600)] <Bosmon> I think that numbers, booleans, and strings include all the reasonable types that could be handled
[19:24:01 CST(-0600)] <Bosmon> In general, never write an index expression like "arr[i]" more than once
[19:24:11 CST(-0600)] <Bosmon> There is both an efficiency as well as a readability argument
[19:24:50 CST(-0600)] <kasper> gotcha
[19:25:02 CST(-0600)] <Bosmon> And so similarly for expandSpec.options.key
[19:25:31 CST(-0600)] <Bosmon> You force the reader, as well as the JS runtime, to verify that the expression really is the same in each case...
[19:26:25 CST(-0600)] <kasper> in terms of the missing check - since I'll be using (what's currently) tmp as a key, shouldn't I expect it to be string only?
[19:27:01 CST(-0600)] <kasper> (I guess numbers or even booleans could be used as keys in my code.. but it just seems ugly)
[19:27:26 CST(-0600)] <Bosmon> numbers can also be keys, and booleans will be converted to be strings which is semi-reasonable
[19:27:32 CST(-0600)] <Bosmon> The string conversion for any other type will be unreasonable
[19:27:44 CST(-0600)] <Bosmon> And there's no reason why your code couldn't be used to construct arrays using numbers as keys
[19:28:10 CST(-0600)] <kasper> yeah, that's true
[19:29:23 CST(-0600)] <kasper> cool, I'll dive into that!
[19:30:32 CST(-0600)] <kasper> but before that, a quick question: looking at the test https://github.com/kaspermarkus/universal/blob/GPII-32-2/gpii/node_modules/settingsHandlers/test/XMLSettingsHandlerTests.js#L27-62 the result will not contain the "b" part of the 'raw' json... Is there a way to by default keep everything that isn't being transformed.. if that makes any sense
[19:30:35 CST(-0600)] <Bosmon> You shouldn't need to fetch fluid.model.transform.getValue if you are a standardTransformFunction
[19:30:40 CST(-0600)] <Bosmon> This value will be in "value" already
[19:31:54 CST(-0600)]
<kasper> basically, I want the: b:
, to be part of the "expected"/output json without it being specified in the transformRules
[19:31:55 CST(-0600)] <Bosmon> The best way would just be to copy the value before deletion - using fluid.copy
[19:32:42 CST(-0600)] <kasper> I dont delete it anywhere.. It automagically disappears
[19:33:02 CST(-0600)] <Bosmon> That's only because right now you have a transform which modified its arguments
[19:33:11 CST(-0600)] <Bosmon> Nothing should automagically disappear.....
[19:33:56 CST(-0600)] <kasper> ok great! I like stuff not magically disappearing! Will do some digging and come back to you with new and improved code
[19:34:09 CST(-0600)] <kasper> thanks a lot for the feedback Bassman!
[19:34:13 CST(-0600)] <Bosmon> awesome KASPAR!
[20:07:43 CST(-0600)] <kasper> Mr. Bosmon: fixed and pushed everything to my repo
[20:08:08 CST(-0600)] <kasper> still cant figure out the "Saga of the disappearing b hash" (TM)
[20:08:48 CST(-0600)] <kasper> I'm now no longer modifying anything, and I'm using the framework to do everything for me, so not sure why it disappears
[20:09:34 CST(-0600)] <kasper> is it perhaps the fluid.model.transformWithRules(json.raw, json.transformRules) call in the test.. is that the correct function to call?
[20:25:23 CST(-0600)] <kasper> ok, better head to bed - thanks a lot for hot-lining me Dr. BassMan - it was hugely helpful!