Questions tagged [code-example]
Questions about using concrete code examples when teaching.
13 questions
1
vote
4
answers
147
views
What is a musical application of linked lists?
When teaching computer programming, occasionally students who are interested in music ask instructors for how a double ended queue could be useful in the music industry.
What is a "real-world&...
8
votes
21
answers
8k
views
What is a real-world example of a for-loop?
The example of a for-loop offered in introductory texts is often very contrived.
For example, we might have:
...
2
votes
5
answers
1k
views
What is an example of class inheritance in every-day life which is easy to write in an object-oriented language?
When a student is first learning about class inheritance it is nice to use an example from every-day life. For example, Plastic Cups are ...
2
votes
0
answers
58
views
Python Code Sharing Forum
I have recently switch from SmallBasic to Python for my introduction to programming course. I have managed to translate everything from one language to the other... with a single difficulty.
Over the ...
1
vote
2
answers
95
views
Help identifying a '90s CYOA-style book with BASIC code listings
Way back in the '90s, I read a choose-your-own-adventure style book,
where most sections ended in a choice of 2 or 3 different pages to turn to
(as is typical).
However, this particular book was ...
5
votes
3
answers
189
views
What is a real-world (production-code) example of a function having default arguments?
I want to teach students about default function arguments.
I have a bad habit of cooking-up contrived examples.
To prove that I am not a student cheating on their homework, I shall provide you with ...
3
votes
3
answers
410
views
“What do you mean it’s plagiarism? It’s from the docs!”
I present to you two scenarios that are different, but not enough to warrant two questions.
Scenario 1: You discover that a student copied some section of the code verbatim from the docs of some ...
3
votes
3
answers
519
views
What's a good example of a static factory method returning instances of subclasses?
One benefit of having a class provide a static factory method rather than public constructors is the method can return an instance of a subclass.
For example, if the class ...
1
vote
1
answer
183
views
Coding assignments for algorithms and data structures?
Do you know of any online resource with ideas/projects for an Algorithms and Data Structures course? Topics in the course include: basic data structures (array, list, stack, queue, priority queue, ...
1
vote
1
answer
237
views
An example that compares a computational with a non-computational thinking approach
I have to teach CT to Standard 5 students (11 to 13 yrs). To explain the concept, I am trying to explain to them how CT is beneficial in today's world. The way I learn and appreciate things is by ...
5
votes
6
answers
680
views
Examples of innocent looking faulty code for shock effect
I'm becoming more and more convinced that starting with an imperative attitude is not doing a favor to the students, especially if it's all about scheduling and repeating some ...
7
votes
7
answers
2k
views
Example for For vs While Loop (in Java)
I'm looking for a set of concrete examples that illustrates good use cases of using a for vs a while loop for beginners. I feel ...
8
votes
5
answers
1k
views
Simple Pointer Examples in C
Thanks to feedback in this thread, I'm beginning to plan how to integrate a basic introduction to pointers into my unit on arrays. Here's a sample program I just wrote up:
...