Milestone 3: Interface
In this third milestone, you'll develop an terminal-based user interface for your coding challenge application using the Curses library. When the program is run, the user is presented a box representing a mystery function. The interface allows the user to enter parameters. These are fed into the box, and the return value is displayed. Once the user has tested enough, they enter code in the box using the syntax you invented in milestone 2.
A good interface makes coding pleasant for your human users. You'll need to make your terminal display easy to understand and navigate. When an error occurs, you'll need to communicate clearly what went wrong.
Curses
Install a port of the Curses library—or some similar library for user interfaces in the terminal—using a package manager for your language. That might be gem
for Ruby, cabal
for Haskell, cargo
for Rust, pip
for Python, or npm
for JavaScript. You will likely have several libraries from which to choose, and your very finite instructor can offer no opinion on which you should choose. Ruby users should revisit the installation instructions on installing and requiring the curses
gem and the recipes on using it.
We are using a textual user interface (TUI) instead of a graphical user interface (GUI) because most GUIs greedily take over your design and engineering time, subverting the other goals we have for this course. Curses, on the other hand, is not a widget- or event-driven system. It keeps the responsibility for drawing content and handling events in your hands.
Mystery Functions
Define at least five mystery functions. For each, create a plain text file from which you can two things: a list of the function's parameter types, and a reference implementation that you can run to get the expected return value. For example, one might create this file for a function that computes an integer average:
int int
sum = a + b
sum / 2
int int sum = a + b sum / 2
It expects two integers, which will be named a
and b
.
The user shouldn't really know about the reference implementations. The game isn't very challenging if they see the code they are supposed to write. But keeping it private is something beyond the scope of this course.
Interactions
The interface of your program must have at least these interaction features:
- The program accepts the mystery function file as a command-line argument.
-
A table of parameter-return cases. There's a column for each parameter to the mystery function, the expected return value, and the actual return value produced by the user's code. Its columns are labeled
a
,b
,c
, ...,expected
, andactual
. The table doesn't need to be scrollable. - A way to input a new parameter-return case.
- A box showing the mystery function that code can be entered in.
- A display panel that shows a program's printed output or an error message.
- A way to run the code and update the output and actual return values in the table.
Arrange the interface as you see fit—just make sure all are visible at the same time. You can assume a window size that works for you; it doesn't need to adapt. Consider using your Curses library's routines for composing the display out of subwindows.
Submission
To submit your milestone, follow the instructions. In particular, do these three things:
- Submit your project to the official GitHub repository that your instructor made for you.
- Record a 3–5 minute screencast of you walking through your code and commenting on it. Do not exceed 5 minutes. Your instructor has many videos to watch. Post it to Canvas Studio according to the instructions.
- Complete the ready date submission form on Canvas.
In your video, demonstrate loading, testing, and solving a couple of your mystery functions.
Don't comment on or show every single line of code in your video. Select a few representative snippets. Do comment on programming language ideas that interest you or challenged you.