Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Change Beyonce albums from array to hash #473

Open
shen-sat opened this issue May 23, 2021 · 2 comments
Open

Change Beyonce albums from array to hash #473

shen-sat opened this issue May 23, 2021 · 2 comments

Comments

@shen-sat
Copy link

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
Copy link
Member

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
Copy link
Collaborator

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 🙂

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants