I'm soon going to introduce product types (C
struct and the like in different languages).
The audience is 17 year old with a long term goal in scientific studies, who have by now a very limited knowledge of programming, mainly only basic loops in C with integers and integer arrays.
I would like to motivate the need and usefulness of this concept, knowing that they're going to say "but we like to do everything with our basic
I would moreover like to propose examples that are interesting, realistic, and with a glimpse to theoretical aspects (I am going to tell them not too late that what we are doing is a cartesian product of the considered base types).
By now, my main idea is the classic points in the plane, maybe complex numbers.
It's very good for my goals (there are reasons why it's a classic), but it has the only disadvantage that the two combined base types are the same.
The risk is that, having them already been exposed to arrays, their first impression of
struct is a needless complication when they could have easily used an array of length 2.
Of course there are all those "real (accountant) world" situations, where I put together a name and an age, or an item and a price and so on. But the students are in science education, I'm not particularly fond of accounting and administrative applications, and most of all I would like to avoid the consolidation of the view that computer science is a tool for accountants. Instead, I'd prefer something about science or computing.
There is also the obvious construction of a linked list in C, but it's too complicated for them: no pointers.
Put somehow differently, from another angle (their): why would I want to define a new type if I do not do software engineering? I can bring all my data in primitive and disaggregated form as I have done for years: the advantage of creating a new type is not worth the burden of having to learn things. Where even is this advantage again? (Writing this line I am remembering of blub language and how it's difficult to make these motivations even for experienced computer scientists, doing it for young students does not seem an easy thing, seen from here).
I'd like instead that they could be put in a situation where they want to construct new types.
(I have asked chatGPT too and it seems to be stuck in my same position).