Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lesson 23 practice " Using right items" task is a unclear and may be teaching bad habits or hardcoding values #982

Open
jman904 opened this issue Aug 24, 2024 · 2 comments
Labels
content Issues with the lessons, practices, including their code examples

Comments

@jman904
Copy link

jman904 commented Aug 24, 2024

I have a programming background so my immediate thought was that loops and conditional checking was what the problem was looking for, especially since the lesson module discusses use of the size() method. Something to the effect of

loop over inventory:
  find the first sword in the inventory array
  use it
loop over inventory:
  to find the first shield in the inventory array
  use it

I wrote this solution assuming the inventory array contained strings, as shown in the associated lesson module, and was surprised to find this was not the case; string matching failed, inventory wasn't really accessible, print functions (e.g., print(inventory.size()) didn't work like in the lesson) and my solution was just super broken. I then realized this was maybe over-engineered and tried the much simpler answer of human visual inspection of the inventory array image on the right and gave a hard-coded answer of use_item(inventory[x]) use_item(inventory[y]) and it worked. This feels wrong from a teaching perspective.

As a long time programmer and teacher, this lesson/practice really bothered me because it teaches a bad habit of hardcoding magic values specific to the example and doesn't teach anything about the dynamic nature of data which is a core concept. I feel like a much better lesson would include more boilerplate code to scan the inventory array, as described above in the pseudocode, and have the student flesh it out the rest of the way to make it functional in a more general purpose way (and teach better habits that more closely reflect real-world use cases). Maybe even just provide the full answer for finding the first sword and leave the student to copy it for finding the shield. Also maybe consider renaming the function pick_sword_and_shield() to be specific to the above pseudocode if making these changes.

@jman904 jman904 added the content Issues with the lessons, practices, including their code examples label Aug 24, 2024
@NathanLovato
Copy link
Contributor

Thank you for the feedback. In general, we are well aware of limits of the app and the series, and to me, it could use a holistic content pass to flesh everything out or even a remake to unlock some technological limitations. I'd like to go through everything and flesh it out more. But we have to focus on our school curriculum.

I think your issue, while I agree it would be something worth introducing, is something beyond the scope of this lesson, whose goal is just introducing how to access elements in an array by index. The lesson could be modified to make this more explicit.

I thought we reused the inventory example after this lesson closer to what you suggest, with dictionaries, but I'll have to check again.

@waptang
Copy link

waptang commented Sep 3, 2024

I also found it unclear how to complete this task. I believe my issue is because the inventory array shown in the code was empty, and it didn't make much sense to iterate over or index into an empty array. I thought I might have to populate the array with something, but I couldn't figure out how to make that make sense.

The starting code:

var inventory = []

func pick_items():
	

It turns out that this array is actually populated with items, so I tried approaching the problem the same way as @jman904 and ran into the same issues. I had to look at the suggested solution to figure out what I was supposed to do for this problem, and that it expected me to just hard-code inventory indexes of the items I wanted to use.

I think if the inventory was declared as var inventory = ["gems", "sword", "shield", ....], or something similar, it would be a bit more intuitive how you're supposed to solve the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content Issues with the lessons, practices, including their code examples
Projects
None yet
Development

No branches or pull requests

3 participants