15
$\begingroup$

I teach programming at a university, at 2 freshmen courses. My students are being introduced to programming for the first time, so we have to teach them about algorithms, variables, control flow, functions, arrays (lists), etc. So this course covers the very basics. And every single year I see the same outcome: they get confused, frustrated, and the common question of "what are these exercises for" always arises. We don't even cover OOP and don't teach anything GUI (only CLI programs, just for them to grasp problem solving and creating algorithms).

So this year I'm trying to take a different approach: I'd like to start my course by showing them how to build a GUI program, at first by just asking them to copy and paste, until they have a working program by the end of the first class. Of course they won't understand a thing at first. But if I show them all the topics "in action" then I can introduce them to the students during the course and review the project we made on our first class.

The thing is, I'm not exactly sure what to show them. I think something like a calculator would be far too simple and might not be too attractive to young, 18-year old students that own mobile devices and see all kinds of cool applications every day. But something like a minesweeper game might be just too big a project for me to show as an example on the first class, considering they will be watching me build a program and trying to mimic what I do without understanding yet, so if this part of my class lasts for too long it might bore them to death :P

I know my course doesn't cover GUI, but I've noticed young students are not familiar at all with command-line, so maybe I can just tell them there are things on the program I'm showcasing that they will learn in future courses. As long as they get to see examples of the more basic stuff.

So, any good suggestions?

$\endgroup$
2
  • $\begingroup$ Something short to keep in mind: not every GUI platform for Python works well together with proper scoping (there are famous libraries where the mainscreen is in the global scope and can't be encapsulated, go figure). Keep in mind to check for such things if you want to teach your students to do it the "right" way, since it appears that's important to you. $\endgroup$
    – Mast
    Commented Jan 12, 2019 at 14:06
  • $\begingroup$ Maybe a to do list? As TodoMVC as famour for anyone who wants to do webapp. $\endgroup$ Commented Oct 12, 2023 at 5:30

9 Answers 9

10
$\begingroup$

Unfortunately, GUI programming is sufficiently different from algorithmic programming that if you start with it students can get the wrong idea about what a program should look like.

For example, when I write an algorithmic program, using good OO techniques, a method of five lines is starting to be too long. The granularity of a good OO program can be very small with the complexity in the interactions between objects rather than in the methods themselves.

But GUI programs typically have long and boring methods that are mostly just messages to library code, rather than being interesting in themselves.

On the other hand, with some preparation, you can/should provide a framework in which the students can work, so that they don't start with an empty page and nothing but language features. You provide a library tailored for their education. Your library can contain the GUI code and they build the algorithms to fit it.

Back in the 1980's the book Karel the Robot by Richard Pattis did a similar thing for structured programming in Pascal. He provided a simulator along with the GUI code. Students wrote programs to make a robot do interesting things. By "interesting", I mean that the system was Turing Complete, so that, in theory, any program could be written within the framework. It actually used a very small, Pascal-like, language with only a few primitives. Students didn't actually program with integers and strings, but with the primitive elements of the simulation. But, Turing Complete.

Karel the Robot has been updated to modern OO standards and versions exist for Java, Python, and Ruby. The Java version has been used for APCS courses and in college level courses as well.

For Java, there is a special resource called the Greenroom that provides many other teacher-written simulation frameworks in which the students program. I don't know of a similar resource for Python, but you could, perhaps tailor some of the ideas there to Python.

$\endgroup$
1
  • 1
    $\begingroup$ I've used hour of code for tools similar to the Greenroom (there are some college level materials and some of the games are great practice sessions for college students, think 15-20 min instead of 4x45 minute lessons) - I've specifically used these games to teach event-driven programming for a web/phone based course I helped with $\endgroup$ Commented Jan 13, 2019 at 4:31
11
$\begingroup$

In my experience, good introductory programming courses meet three overarching goals:

  1. Empower students to create simple programs outside of the scope of the class by giving them the technical skills and the practice to begin being independent. This includes teaching the basics of one usable language.
  2. Inspire students to continue learning and using their skills once the class ends (independently and/or by signing up for the next class in the sequence).
  3. Prepare students for the next step in their learning. In many cases, this means that certain topics and concepts must be covered so that students can enter the next class at the correct level. It should also include giving students practice with the skills needed for basic independent learning including debugging, googling to find solutions to problems, and initial exposure to reading and utilizing documentation.

It sounds like you have seen issues with goal number two, where your students do not feel inspired. However, I am concerned that introducing your introductory students to GUI building right off the bat will jeopardize goal number one. GUI has a lot of overhead, and as you said, your students will not understand what they are doing and will be frustrated by their inability to build anything without heavy guidance/pre-built pieces.

My suggestion is to strike a middle balance. Have them build command line applications that they fully understand, but that are interesting or useful in some way. Better yet, give them some choice in which projects to tackle so that they are more invested.

Here are some neat things that students of mine have built in the command line without any OOP:

  • Guess the Number Game (the computer generates a number and tells the user if they are too high or too low)
  • Fortune Teller Games (using arrays and randomization)
  • Personality Quiz
  • Hangman Game
  • Random Name Generator
  • Text Based Adventure
  • Reverse Guess the Number Game (The user picks a number and the computer has to guess. This is a great jumping off point for first introducing the concept of an algorithm, since the program needs to make "smart" decisions.)
  • Minesweeper, battleship, connect four, etc. are great for 2D arrays/lists when you get there
  • Flash Card Application (students can even actually use this to study for tests for other classes!)
  • Calculator (if that's too easy, have it do harder math. Can your students build a calculator that solves algebraic equations? Can they make it take derivatives? Solve trig problems? You can apply it to whatever math they likely are learning at the time)
  • To do list manager
  • An application that manages a student roster or waitlist for a class

I hope these ideas help!

$\endgroup$
3
  • 5
    $\begingroup$ These are great ideas for text-based games; that's what I was going to suggest but your list is more complete than mine would have been. Welcome to the site; hope you stick around! :) $\endgroup$
    – Wildcard
    Commented Jan 12, 2019 at 1:29
  • 4
    $\begingroup$ I disagree that debugging skills should be considered as independent learning. They should be covered by the course itself. $\endgroup$
    – Bergi
    Commented Jan 12, 2019 at 17:49
  • $\begingroup$ Ah, I may have not been clear. I think that students should be explicitly taught the core skills that enable them to work independently, and I included debugging in that list. I certainly don't think that students should have to learn debugging on their own. Rather, that learning it enables them to be more independent. $\endgroup$ Commented Jan 12, 2019 at 22:16
3
$\begingroup$

There is a good class on Coursera for interactive game programming in Python by some professors from Rice University, which I used when I started learning Python. It's really good at introducing the ideas very gradually, but eventually creates a pretty sophisticated game.

There might be some ideas you can get from the course, or maybe you could do an inverted classroom? https://www.coursera.org/learn/interactive-python-1

$\endgroup$
2
$\begingroup$

What about a circuit python project to finish off the semester? There's no GUI as such, but you can show them a cool demo, then have them learn codes that builds towards some kind of cool interactive project. Doesn't have to be big or expensive, but lets them truly make something tangible out of their code. An Arduino was really the first thing that got me motivated to stick with programming.

$\endgroup$
2
  • 2
    $\begingroup$ Please say more about "circuit python". An example would be good. What is a "cool" demo or a "cool interactive project"? $\endgroup$
    – Buffy
    Commented Jan 12, 2019 at 20:36
  • $\begingroup$ Depends on the scope of the class, so I'd say it's up to the OP. My point really is that building something practical, and hands on, can help ground programming. Turning LEDs different colors at the touch of a button, or having them activate based on a particular level of sound or light, can help turn more abstract concepts into something tangible. $\endgroup$
    – Britton
    Commented Jan 13, 2019 at 15:43
2
$\begingroup$

I've tried running some demos before starting class and collecting preferences of different children. The list of demo programs is here https://gist.github.com/danbst/ae4fd7cbb1ea97d5efbc80bd06b50075, all of which can run out-of-box on any python installation (with tkinter).

Of those the most complicated is Minesweeper using TKinter https://bit.ly/2ViDFAP.

But, most interestingly, children often like terminal programs, not just GUI. Here's my collection of various preferences:

  • labyrinth (terminal)
  • ascii cats animation, cowboy (terminal game), minesweeper (Tk), nonuniform fractal trees (turtle)
  • labyrinth, fractal trees
  • diagonal maze (terminal), DNA animation (terminal), Hilbert curve (turtle), ascii-art digital clock (terminal), Matrix-like animation (terminal)
  • minesweeper, cowboy
  • Koch snowflake (turtle), minesweeper
  • Mona Lisa (turtle drawing image), Koch snowflake, DNA animation, World map (terminal)

As you see, even though there were GUI and graphical programs, many children still liked terminal-only demos, or interactive. The "cowboy" program (https://bit.ly/37pNqmk) is ridiculously simple, but still generates "fun".

$\endgroup$
2
$\begingroup$

PySimpleGUI will do what you're after, starting right from the start of teaching Python. The eCookbook will enable you to see how the architecture looks/works without installing anyone on your computer. If you like it, you can pip install PySimpleGUI and start coding desktop GUI applications. Most courses wait until object-oriented programming is taught, which means at the end of the course, if at all.

PySimpleGUI was designed to get around this problem, enabling beginners to make GUI applications without limiting the problem set to only simple applications. The "Simple" is a description of the ease of programming GUIs, not the simplicity/complexity of the GUI and the problems it can solve.

(Full disclosure, PSG is a project that I created, maintain, and extend. However, I'm not here trying to promoting myself (I dislike fame), but instead trying to be helpful.)

$\endgroup$
4
  • 2
    $\begingroup$ Thank you for following the self-promotion rules. We appreciate genuinely helpful answers that also disclose people's associations. (It might be a good idea to place that disclosure in the answer itself, though it's certainly clear in your username.) $\endgroup$
    – Ben I.
    Commented Oct 11, 2023 at 14:14
  • 1
    $\begingroup$ It didn't break any rules - that's even why I commented with a thank you. The post is both helpful and well received by the community, and you're good! I am modifying the edit, because it's commentary and not truly part of an answer. We are a small community, and I hope we see more of you. $\endgroup$
    – Ben I.
    Commented Oct 12, 2023 at 13:21
  • 1
    $\begingroup$ Are you okay with that edit? $\endgroup$
    – Ben I.
    Commented Oct 12, 2023 at 13:26
  • $\begingroup$ Of course! Thank you so much for the kindness and help. $\endgroup$ Commented Oct 12, 2023 at 13:58
1
$\begingroup$

There is little point these days in making a GUI program, except in the most rare cases, especially with Python. In the age of the internet, most programs are best served as web apps. I expect this will be most relevant to your students' interests as well. For Python I would suggest starting with Flask or Django. There are good Django tutorials here:

And I like this Flask one:

All of these should show you how to make a basic app, which has a GUI in the form of a web interface.

You might also consider something more visual in the form of basic data analysis and plotting with Jupyter notebooks.

$\endgroup$
5
  • 4
    $\begingroup$ This requires the students to understand all kinds of web techniques, most notably HTTP and HTML, which might be too advanced for freshmen students (without being the actual subject of the course). It makes more sense at a later stage of the curriculum when they already learned about network stuff. $\endgroup$
    – Bergi
    Commented Jan 12, 2019 at 17:57
  • $\begingroup$ How is a web app not a GUI? The client is quite graphic usually. $\endgroup$
    – Mast
    Commented Jan 12, 2019 at 21:22
  • $\begingroup$ @mast with Python? the web app would be a GUI app (if its actually an app not an interface) but its not event driven like a standalone GUI app would be (or rather to make it event driven you would have to switch to Javascript) - so it would end up not teaching the students the same lessons (or language). I wouldn't say standalone GUIs are rare - remember cell phone games and tools as well as office applications are still typically stand-alones. Just depends on the field (like I will probably never write another serious webapp but GUIs? yeah, all the time in C# with python backend) $\endgroup$ Commented Jan 13, 2019 at 4:05
  • $\begingroup$ @JGreenwell thats what I was getting at. Creating the actual GUI for those apps is often not done with Python. The skills to build a web app may be outside the scope of a freshman curriculum, but you should not forget that this is probably why those students signed up for Computer Science in the first place; to learn mainstream app building techniques. I doubt they signed up because they wanted to learn algorithms. And both Flask and Django are easy enough to learn from the tutorials I posted, I taught myself both using these. $\endgroup$ Commented Jan 13, 2019 at 10:58
  • 1
    $\begingroup$ Back-end web gives a pretty poor coolness-to-difficulty ratio needed to keep new learners engaged. Data persistence isn't interesting until one has already created a front-end game or todo list and wants to keep a high score table (and localStorage isn't exciting any more) or add multiplayer features. This lack of visual options (aside from turtle) is part of why I find Python to be a less engaging language for new students than JS/HTML5. $\endgroup$
    – ggorlen
    Commented Mar 18, 2022 at 21:37
1
$\begingroup$

On command line

To make command line programs make sense, you need to first teach Unix (Or another OS with a workable command line: VMS, Amiga-dos, sorry I can't think of any others that are still relevant).

When one can see the value in a powerful command line, where one can complete tasks much more quickly and with less pain, then it becomes obvious why one would write ones own command line programs.

On GUI

Yes for graphical programming, but this is not GUI programming.

I have used python turtle, it aids learning because it gives immediate feedback. I have used it to teach the basics, in schools. It could also be used to teach algorithms: First teach basics, then add drawing of data sets, then …

UnPlugged

Also consider teaching some of it unplugged. You can teach algorithms, by having the students be the data, by having a student direct, by having a student explain, by using props e.g. backs of cards, white boards, paper, mini-whiteboards, …

See https://csunplugged.org/en/ for some ideas. This site is aimed at primary school teachers, but most of it can be adapted.

$\endgroup$
1
$\begingroup$

I teach event-driven GUI programming in Java. This requires machinery. First of all, students need to be good at writing functions and procedural programs. Secondly, they need to understand polymorphism and inheritance, as these are vital tools. So, we are beyond the range of beginners here.

However, if you teaching Java, GUIs are a compelling use case for the whole inheritance mechanism. Java8 lambdas make the writing of callbacks simpler and more fun. I use the JavaFX framework for this purpose. If you are doing this in java11, it is tricky to get set up and configured.

I don't see this as a game for novices.

$\endgroup$

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.