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

(17) New exercise | Flatten #445

Closed
wants to merge 5 commits into from

Conversation

nik-rev
Copy link
Contributor

@nik-rev nik-rev commented Mar 23, 2024

Because

It was decided to add new recursion exercises

Previous

This PR

  • Adds exercise 17

Issue

Related to #27265

Additional Information

Pull Request Requirements

  • I have thoroughly read and understand The Odin Project Contributing Guide
  • The title of this PR follows the location of change: brief description of change format, e.g. 01_helloWorld: Update test cases
  • The Because section summarizes the reason for this PR
  • The This PR section has a bullet point list describing the changes in this PR
  • If this PR addresses an open issue, it is linked in the Issue section
  • If this PR includes any changes that affect the solution of an exercise, I've also updated the solution in the /solutions folder

@nik-rev nik-rev marked this pull request as draft March 23, 2024 15:06
@nik-rev nik-rev changed the title New exercise | Flatten (17) New exercise | Flatten Mar 23, 2024
@nik-rev nik-rev marked this pull request as ready for review April 6, 2024 14:19
@CouchofTomato CouchofTomato requested review from a team and bycdiaz and removed request for a team April 7, 2024 15:37
Copy link
Contributor

@MaoShizhong MaoShizhong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we think about the benefit of this exercise in context, given that Array.prototype.flat exists which is identical to this, other than the default depth is 1 instead of Infinity?

While any kind of practice with recursion is still practice with recursion, I feel like if we're to create new exercises for that purpose, they ideally should be:

  • problems that are naturally more suited to using some kind of recursive approach than pure iteration. An exception can definitely be made for the Factorial exercise, given it's the first one and also a classic for dipping your toe in recursion. But later exercises should probably look to fit this bill.
  • something that isn't just recreating a built-in function. If we want practice with recursion, we probably would be better off solving a problem that would need us to build something recursively, as opposed to recreating a built-in where in the real world, we'd just use the built-in.

My personal opinion is that this exercise doesn't meet the second criteria, where a different exercise that does would be more appropriate while still affording the learner plenty of good practice with recursion.

@JoshDevHub tagging you for your opinion since you did mention something among these lines at some point.

@nik-rev
Copy link
Contributor Author

nik-rev commented Apr 7, 2024

What do we think about the benefit of this exercise in context, given that Array.prototype.flat exists which is identical to this, other than the default depth is 1 instead of Infinity?

While any kind of practice with recursion is still practice with recursion, I feel like if we're to create new exercises for that purpose, they ideally should be:

  • problems that are naturally more suited to using some kind of recursive approach than pure iteration. An exception can definitely be made for the Factorial exercise, given it's the first one and also a classic for dipping your toe in recursion. But later exercises should probably look to fit this bill.
  • something that isn't just recreating a built-in function. If we want practice with recursion, we probably would be better off solving a problem that would need us to build something recursively, as opposed to recreating a built-in where in the real world, we'd just use the built-in.

My personal opinion is that this exercise doesn't meet the second criteria, where a different exercise that does would be more appropriate while still affording the learner plenty of good practice with recursion.

@JoshDevHub tagging you for your opinion since you did mention something among these lines at some point.

I honestly don't think it is a big deal that flat is already a built-in array method. At the end of the day, these exercises are mostly to practice recursion and this problem is fairly challenging and interesting to solve.

Take the HashMap project for example, you're not going to implement your own hashmap and probably going to use something like a Set in the real world. But it is a nice learning experience to kind of get a feel for how things work under the hood.

Sure, it may be better to have more exercises that focus on other tasks, and are not necessarily about re-creating a built-in, however I don't think there's any harm in leaving this one in. People will still learn a lot if they complete it.

Regardless, I'm content if you still think it should be removed. If we are at this point though, I think its now important to decide which exercises we want to add soon.

I have added a comment to the original issue as it is certaintly more relevant there than in this PR.

TheOdinProject/curriculum#27265 (comment)

@MaoShizhong
Copy link
Contributor

MaoShizhong commented Apr 8, 2024

This is just my opinion though. If others disagree and think flatten would be perfectly fine, then by all means, let's include it. If that is to be the case, we should frame the exercise to specifically be a recreation of Array.prototype.flat.

The difference I find is that with the Hash Map lesson and project, you're not tasked to recreate Sets or Maps. Also, the pedagogy behind the project is to practise some lower level concepts like hashing, collisions, growth etc. To practice those, you kinda need to create a hash map from scratch (again, not a Set or Map - just a barebones hash map according to that spec). The intent of that project is very different.

In this case, the concept we want learners to practice is recursion, especially the recognition of patterns and problems that lends themselves well to recursion. Doing so is not particularly tightly bound to flattening nested arrays, so I don't see it as particularly necessary to make people recreate that built-in, when there are other exercises that can pose more unique and valuable recursive problems. Hope that helps my perspective make more sense?

@nik-rev
Copy link
Contributor Author

nik-rev commented Apr 8, 2024

This is just my opinion though. If others disagree and think flatten would be perfectly fine, then by all means, let's include it. If that is to be the case, we should frame the exercise to specifically be a recreation of Array.prototype.flat.

The difference I find is that with the Hash Map lesson and project, you're not tasked to recreate Sets or Maps. Also, the pedagogy behind the project is to practise some lower level concepts like hashing, collisions, growth etc. To practice those, you kinda need to create a hash map from scratch (again, not a Set or Map - just a barebones hash map according to that spec). The intent of that project is very different.

In this case, the concept we want learners to practice is recursion, especially the recognition of patterns and problems that lends themselves well to recursion. Doing so is not particularly tightly bound to flattening nested arrays, so I don't see it as particularly necessary to make people recreate that built-in, when there are other exercises that can pose more unique and valuable recursive problems. Hope that helps my perspective make more sense?

I see where you are coming from, thanks for clarifying it! You make a good point about the hash map project.

@nik-rev nik-rev closed this Apr 24, 2024
@nik-rev
Copy link
Contributor Author

nik-rev commented Apr 24, 2024

Closing because we decided not to include this exercise! It is about mimicing the functionality of a built-in method and it would be better to have learners complete challenges that are more like real world problems.

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

Successfully merging this pull request may close these issues.

2 participants