Skip to content

some smallish refactoring#4742

Merged
Bjvanminnen merged 6 commits into
stagingfrom
configCleanup
Oct 26, 2015
Merged

some smallish refactoring#4742
Bjvanminnen merged 6 commits into
stagingfrom
configCleanup

Conversation

@Bjvanminnen

Copy link
Copy Markdown
Contributor

I've been spending a bunch of time dealing with droplet config recently, and find this code pretty confusing. In general, I have a couple of complaints:
(1) We seem to use this config for a bunch of different purposes (palettes, interpreter, autocompletion, etc).
(2) We pass around this config around to a bunch of different places, and it's difficult to tell where it's being mutated.

This PR does a little bit to attempt to address number 2. There are two changes in here.

The first is to have mergeCategoriesWithConfig use $.extend, which I think makes it clearer exactly what's happening (and more concise).

The second is to change generateDropletModeOptions so that instead of calling functions that mutate modeOptions, it calls functions that return it some data that it then merges into modeOptions. I also moved the logic from setTitlesToFuncNamesForDocumentedBlocks to be inside of getModeOptionFunctionsFromConfig (formerly populateModeOptionsFromConfigBlocks).

@davidsbailey

Copy link
Copy Markdown
Member

it looks like mergeFunctionsWithConfig could be using $.extend as well

@davidsbailey

Copy link
Copy Markdown
Member

LGTM. nice refactor, nice test

@Bjvanminnen Bjvanminnen force-pushed the configCleanup branch 2 times, most recently from f5c2e77 to 7995fa2 Compare October 23, 2015 18:39
Comment thread apps/src/dropletUtils.js

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be pretty much the same as before. I just removed a level of nesting, and then renamed some variables (I find it hard to distinguish things like blockSet vs. blockSets). Also, we previously did var block = blocks[i]; but then proceeded to use blocks[i] everywhere instead of block.

@Bjvanminnen

Copy link
Copy Markdown
Contributor Author

@davidsbailey I made some more changes to this, could you take another look? There's also a lot of text description that I'm happy to talk through in person if that would help.

@Bjvanminnen

Copy link
Copy Markdown
Contributor Author

Actually looks like CircleCI failed on some of my new tests (I could have sworn they passed for me locally), so maybe hold off until I get those passing again.

@Bjvanminnen

Copy link
Copy Markdown
Contributor Author

Fixed tests

@davidsbailey

Copy link
Copy Markdown
Member

sorry I missed this. looking now

Comment thread apps/src/dropletUtils.js

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be helpful to add a type param for codeFunctions, and (though it may not be 100% standard) dropletConfig.blocks

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. There are quite a few possible member fields I think, but probably worth while to make an attempt to at least start listing those.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never mind the first part, I see that codeFunctions is well documented below. It might still be helpful to know what dropletConfig.blocks is

@davidsbailey

Copy link
Copy Markdown
Member

LGTM

@davidsbailey

Copy link
Copy Markdown
Member

nice tests!

Bjvanminnen added a commit that referenced this pull request Oct 26, 2015
@Bjvanminnen Bjvanminnen merged commit 0578c5c into staging Oct 26, 2015
@Bjvanminnen Bjvanminnen deleted the configCleanup branch October 26, 2015 20:22
deploy-code-org added a commit that referenced this pull request Oct 26, 2015
0578c5c Merge pull request #4742 from code-dot-org/configCleanup (Bjvanminnen)
75af0cc Merge pull request #4815 from code-dot-org/levelbuilder (Laurel)
dfe9ba3 Merge pull request #4814 from code-dot-org/fix-applab-most-recent (Josh Lory)
ff5f925 content changes (-laurel) (Continuous Integration)
e3cd8cf When logging in, auth before `most_recent` to get the correct project (Josh Lory)
8083ad5 Merge pull request #4813 from code-dot-org/staging (Laurel)
b5fa69b Merge pull request #4811 from code-dot-org/script-admin_required2 (Laurel)
Bjvanminnen added a commit that referenced this pull request Oct 26, 2015
This reverts commit 0578c5c, reversing
changes made to 75af0cc.
Bjvanminnen added a commit that referenced this pull request Oct 26, 2015
Revert "Merge pull request #4742 from code-dot-org/configCleanup"
deploy-code-org added a commit that referenced this pull request Oct 26, 2015
a2a2fe4 Merge pull request #4826 from code-dot-org/revertConfigCleanup (Bjvanminnen)
dcf08a1 Revert "Merge pull request #4742 from code-dot-org/configCleanup" (Brent Van Minnen)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants