Skip to content

Conversation

@pjcozzi
Copy link
Contributor

@pjcozzi pjcozzi commented Dec 8, 2015

Please provide technical feedback by end of Thursday:

Commit corrections, improvements, and new sections directly to this branch, coding-guide. Maintain the concise writing style and still try to provide context. If you don't have commit access, just leave a comment in this PR.

I went through much of the Cesium codebase and documented established practices in this guide. The scope of this PR is to finish and edit the guide, not to suggest changes to the current practices. Please open separate issues for those discussions or add them to #2524 (Cesium 2.0).

TODO

Copy link
Contributor

Choose a reason for hiding this comment

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

Missing close } here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, fixed. Feel free to just fix things like this. :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest a different example here. Normally we would declare a file-scoped var for documentation reasons, and then return freezeObject(Blah); at the end. (this example is from a private enum)

Copy link
Contributor

Choose a reason for hiding this comment

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

One typical situation where private instance functions are useful is with our events, which accept function/scope pairs, in order to avoid allocating a closure just to bind this. Perhaps that's too esoteric to bother mentioning here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Up to you. Add it if you want. I have only used our events in one or two places.

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Dec 10, 2015

Reminder: please provide tech edits and feedback by end of today.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've actually been tempted to open a pull request to fix this, there's never be a good reason for use strict to be in double quotes and it's one of the oddest things about our code base. I know you are just reporting what's already in the code here, just bringing this up in case anyone has an objection.

Also, you might want to mention that we use double quotes in HTML.

Copy link
Contributor

Choose a reason for hiding this comment

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

We should also mention somewhere near the top of the document that all Cesium code uses strict mode.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've actually been tempted to open a pull request to fix this

Good beginner issue: #3345.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it's immediately clear to readers why this is bad. Maybe explain in more detail that var c = cartesian gets removed at build time and changes the behavior of the code.

@mramato
Copy link
Contributor

mramato commented Dec 10, 2015

Good write up. Definitely better than our old one. I can add the Workers and Promises sections when I have spare time, but that's not something I can do right away. We should write up a GitHub issue for these things so we don't forget about them.

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Dec 11, 2015

  • Avoid redundant nested property access. This
scene._state.isSkyAtmosphereVisible = true
scene._state.isSunVisible = true;
scene._state.isMoonVisible = false;

is better written as

var state = scene._state;
state.isSkyAtmosphereVisible = true
state.isSunVisible = true;
state.isMoonVisible = false;

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Dec 12, 2015

  • Change example constructor functions in the guide to be, for example,
function Model(options) {

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Dec 15, 2015

Thanks for the feedback. Updated.

@slchow can you please copyedit this and open a pull request into this branch, coding-guide?

@slchow slchow mentioned this pull request Dec 15, 2015
@pjcozzi
Copy link
Contributor Author

pjcozzi commented Dec 16, 2015

This is ready to merge.

@pjcozzi pjcozzi mentioned this pull request Dec 16, 2015
mramato added a commit that referenced this pull request Dec 16, 2015
@mramato mramato merged commit 2cce011 into master Dec 16, 2015
@mramato mramato deleted the coding-guide branch December 16, 2015 19:08
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.

5 participants