In general I don't mind them looking up stuff online, but the other day a bunch of them really ticked me off when they found a solution online that was pretty much explicitly marked as "bad idea" in the lecture slides & book. What explains this tendency to search for everything online and what do I do against it?

In case you're interested: the problem was "how to generate random numbers in C++". ChatGPT and other sources give you a nice bit of code with a modern Mersenne Twister generator, properly seeded. ChatGPT gives you a suitable main program that demonstrates it. Sure. But don't put those lines in a function because then you re-seed the generator every time you call the function, and you basically use the seed function as the generator. Solution: declare everything static. It's in my notes.

Other example. They do several exercises about C++ "smart pointers" which are (repeatedly) told are better than old-style C pointers, which I in fact don't teach. Still the latter show up in project code. Not in homework code, because there I explicitly tell them what to do.

How about I conclude lectures with "Idioms to avoid and that will be downgraded"?

  • $\begingroup$ Can you come up with a test case where the results differ depending on whether they follow your notes or use the online solution? If so, a failed test case might get the students attention. $\endgroup$ Dec 19, 2023 at 16:33
  • $\begingroup$ @FritzSieker That can be very hard in the case of random (testing a rng is tough!) or impossible/irrelevant if they have a working code using "unapproved" style. $\endgroup$ Dec 19, 2023 at 16:56
  • 1
    $\begingroup$ 'How about I conclude lectures with "Idioms to avoid and that will be downgraded"?' it's going to be hard to list them all. It's difficult to grade code style since it's somewhat subjective, but that's a different problem than trying to get students to use textbooks rather than ChatGPT, which is also difficult. $\endgroup$
    – ggorlen
    Dec 19, 2023 at 19:41

2 Answers 2


TL;DR Alas, that won't happen.

It's very hard for authors to make their information as accessible as Google or ChatGPT results. So, when competing with these resources, you'll always loose in the typical lazy student/developer mindset. The radical conclusion would be to give up on lecture slides or books as a reference resource.

Better embrace Google & Co and have some lectures about how to best use them. Teach your students how they can decide whether an example found online matches the current task.

Insist that software has to fulfill requirements, and e.g. random number generators have to produce a nice distribution of values if called multiple times. Provide a testbed that checks whether the students' random number generators fulfill at least the most basic properties.

Teach them what to do if their solution attempt fails, i.e. analyzing and debugging their programs.

And regarding random number generators:

  • Is it important for a professional developer to be able to write a good random number generator? I don't think so. Never written one in my 30+ yrs developer career.
  • Is it important to understand what properties a good random number generator should have? Absolutely. Especially important is the ability to switch between two different usages: an unpredictable behaviour in production code, and a reproducible one for testing purposes.
  • 1
    $\begingroup$ Random numbers are a subtle issue that I'd rather not focus on. Students in their first semester are barely able to use them, certainly not to assess them. Btw, I'm not asking them to write one: only to use it properly. $\endgroup$ Dec 19, 2023 at 14:23

I think in this day and age it's unavoidable. Short of cutting off the internet, students are going to look things up when stuck. And heck, even the pros will sometimes resort to getting ideas from StackOverflow once in a while.

In my class, I have a "Many Small Programs" approach which takes the form of mini-projects that have to be done in groups. I teach an elective that meets 3 times a week. Each project is broken up into modules that an individual student can do in 30-40 minutes. Before they turn on their computers they'd at least have to write down the task in pseudocode using paper and pencil, if for nothing else to show that they've planned it out before actually coding.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.