hsf-training / cpluspluscourse

C++ Course Taught at CERN, from Sebastien Ponce (LHCb)
Apache License 2.0
177 stars 67 forks source link

Better exercises for lambda and stl #416

Open HereThereBeDragons opened 1 year ago

HereThereBeDragons commented 1 year ago

After having a longer discussion yesterday with bernhard, i got the following idea how the difficulty of understanding lambdas and stl could be eased.

I would suggest the following exercises (in order of execution):

  1. lambda simple: exercise to write simple lambda function, maybe even start with rewritting an existing function by a lambda - no usage of stl
  2. lambda and stl - simple: rewrite an (existing & fully functioning) program that uses stl with function object to replace these function objects with lambdas
  3. lambda and stl - advanced: have an unfinished program where stl functions and their respective lambdas must be added. could be that in the readme there is a list of possible stl functions to decide from
welcome[bot] commented 1 year ago

Thanks for opening your first issue here! If you have any questions, feel free to mention one of the conveners, previous contributors, or attend our weekly meeting (see https://hepsoftwarefoundation.org/workinggroups/training.html). Also, sometimes issues go unnoticed, so don't hesitate to @mention some of us, if we do not come back to you within a few days.

bernhardmgruber commented 1 year ago

Thx @HereThereBeDragons for sketching that outline! I indeed think that the stl exercise mixes a lot of things at the moment and that we could improve it.

Historically, we had separate exercises for the STL and for lambdas. However: in the opposite order. We first introduced the STL using function objects, and then we had an exercise to convert a program using STL with function objects into a program using STL and lambdas. I campaigned for merging the two because I don't want students to practice writing function objects. Lambdas are just superior in most situations. That explains the status quo.

I especially like your suggestion 1. of having a dedicated exercise on lambda functions without any STL. I would then still combine 2. and 3., because the starting point for the current stl exercise already gives you all the names of the STL functions you should use. I think we may even had your suggestion 2. at some point, but it took too long for the students to figure out how to refactor a non-STL program into an STL one. Which is why we provide the combined approach.

HereThereBeDragons commented 1 year ago

I personally would keep 2. and 3. separate and have 3. as bonus exercise for the essential course and as a quick refresher exercise for the advanced course.

Also I personally would vary a bit that you use more than just 2 STL functions

stale[bot] commented 8 months ago

This issue or pull request has been automatically marked as stale because it has not had recent activity. Please manually close it, if it is no longer relevant, or ask for help or support to help getting it unstuck. Let me bring this to the attention of @klieret @wdconinc @michmx for now.