itscodenation / curriculum-15-16

The ScriptEd Foundations and Advanced Course curriculum for the 2015-2016 school year
52 stars 53 forks source link

Use more conventional language for JavaScript objects (née hashes) #21

Closed outoftime closed 8 years ago

outoftime commented 8 years ago

JavaScript does not have a built-in Hash data type—the data structure in question is unambiguously an Object. The difference is somewhat arcane and certainly not relevant at an introductory level, but it is important to use the right vocabulary.

Similarly, the elements of an object are referred to as properties, which have a name and a value. The term “key” is not commonly used, nor is “key-value pair”, when talking about JavaScript properties. (These would be the appropriate terms if the structure in question were in fact a Hash).

For evidence, check the ECMAScript 5 specification—the word “hash” does not appear at all in the specification, whereas “object” occurs 1,364 times. Similarly, the word “key” only occurs a handful of times, in unrelated contexts; “property” or “properties” appears 1,350 times.

The idea here is not to be nitpicky—it’s important to use the right terminology because that’s what the students will encounter when interacting with external resources. W3Schools, Codecademy, Khan Academy, and MDN all use the term Object.

This pull request updates the materials for Unit 14 to use the conventional terminology.


As an aside, I think there’s a bigger problem with Unit 14, as it emphasizes the use of objects as data structures containing mappings of homogeneous names and values, e.g.:

{
  en: 'English',
  jp: 'Japanese',
  es: 'Spanish'
}

While this is a common use of objects in JavaScript, it’s not really the main one; objects are most canonically used to group together heterogeneous properties into a single piece of information, e.g.:

{
  name: 'Mat',
  age: 32,
  birthplace: 'Washington, DC'
}

So the emphasis on using objects as a collection data structure rather than as a model for real-world concepts is kind of missing the point, and I suspect will make it more confusing for students who are introduced to things such as constructors and methods in advanced JavaScript.

However, fixing this problem would involve basically a rewrite of the lesson, which I think is more appropriate for a Twitch pull request ; )

bonniee commented 8 years ago

+1 -- this was confusing to me when I went through these lesson plans. I don't know any JavaScript folks who would use a term other than object here.