Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linting / coding styles #5

Open
coleshaw opened this issue Sep 19, 2017 · 1 comment
Open

Linting / coding styles #5

coleshaw opened this issue Sep 19, 2017 · 1 comment

Comments

@coleshaw
Copy link
Contributor

Kind of nit-picky, but there are some pycharm plugins for linting JavaScript, that I would encourage you to install them. I just see some random things like:

	submitData(data) {
		var xhr = new XMLHttpRequest();

        // This part gets unplatform's session uuid if available
        // and creates a json string for the ajax POST. The /appdata/ api
        // is pretty flexible for the params field. Timestamps are generated
        // server-side & don't need to be included.
		var data_string = {}
        
        // if you want to test with a session id, you can set
        // document.cookie = "session_uuid=test"
		data_string['session_id'] = this.uuid;
        
        
		for (var key in data) {data_string[key] = data[key];};
        
        var qbank = { data : data_string }
        qbank = JSON.stringify(qbank);

And linting the code would make it a little more readable...

@coleshaw
Copy link
Contributor Author

coleshaw commented Sep 20, 2017

In playlevel.js and prefabs.js, I've seen a lot of nesting of setInterval methods to do some animations, etc. If you can break out the functions, you can avoid callback purgatory (or whatever you want to call it). One example starts around line 144 in playlevel.js. Breaking out these methods might also make them more testable too, although the ones I saw are mostly animation-related, so not sure how you would test them anyways.

A "better" option than just breaking out into functions is to use promises, with a library like the q library.

But it would help with readability / coding style.

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

No branches or pull requests

1 participant