CodeYourFuture / syllabus-archive

[ARCHIVED] Please use https://github.com/CodeYourFuture/syllabus
https://codeyourfuture.github.io/syllabus-master
74 stars 115 forks source link

Change Beyonce albums from array to hash #473

Open shen-sat opened 3 years ago

shen-sat commented 3 years ago

I was involved in a lesson (as a teaching assistant) and came across the following scenario which confised the students (as well as me!)

In node week 2 we introduce a new variable albumsData which is an array of Beyonce albums.

When we make the request GET /albums/10, we ideally want to return the album with an id of 10. However, some students (and teachers) interpreted this as returning the album with an index of 10 (because albumsDatais an array).

In order to avoid this confusion (and to reflect real-world applications) we should change albumsData into a hash instead of an array, and return objects by their id instead of looping through albumsData and returning albums of their index.

textbook commented 3 years ago

I think the array as a return to GET /<resource>s is more conventional than an object mapping the IDs. One thing that might help is making the IDs more obviously not indices, e.g. using UUIDs.

40thieves commented 3 years ago

Hi thanks for reporting this, I just want to make note that this repo is for the old archived version of the syllabus. You'll likely get a better response if you move this over to https://github.com/codeyourfuture/syllabus 🙂