JGCRI / programing-resources

Repo for JGCRI software training resources
1 stars 0 forks source link

6. Plan for Mistakes - take advantage of language features #1

Closed bpbond closed 6 years ago

bpbond commented 7 years ago

The first sentence should probably say "will inevitably have mistakes"?

This section covers, in a language-neutral way:

To this I'd probably add:

For example (revisiting the example from section 3), if working in many languages you can say

const OCEAN_BASINS = 4

which provides both syntactic and semantic support for the fact that this is a constant and should not be messed with. Even in languages like R that don't support this, there are similar constructs (lockBinding).

ssmithClimate commented 7 years ago

Good point.

Question, is (lockBinding) sometime an average user would tend to use? (I tried looking it up, but couldn't find a simple explanation of how to use it.)

bpbond commented 7 years ago

No, not at all, and probably not worth mentioning here. The point would be to take advantage of defensive features in whatever language you're working in.

ssmithClimate commented 7 years ago

Example added