Naming things seems to be a continual problem with programming students. I’ve written about this before (two years ago A Rose By Any Other Name Gives An Error ). I can’t seem to get a handle on it with students. I think part of the problem is that students are good with ambiguity and inference. If you call a student by the wrong name or a diminutive they don't’ use themselves you may get a correction (think warning in computer speak) but they know who you are talking to/about. Compilers are a lot more fussy.
Case-sensitive languages differentiate between “question” and “question.” Forget about adding extra letters or misspelling a name.
Somehow students have trouble looking that closely at words. I’m not sure if that is because they are too used to filling in the blanks of misspelled words or something else? I do notice that I see a lot of typos and spelling errors in other written work they do. Even though there are spell checking tools built into editors.
Part of the problem may be error messages. Well, that students don’t always read the error messages is part one. But even when they do the messages are not always helpful enough. “Variable does not exist in current context” is pretty meaningful for an experienced programmer. We understand things like scope for one thing. We also know to look for spelling differences. Students sometimes have trouble parsing that all out though. It is something that comes with experience.
Unclear error messages have long been a problem. I think that maybe it is because the people who write the messages have too much knowledge and so assume too much knowledge on the part of programmers. Then again most development tools are designed for experienced programmers and not beginners.
I wonder if smart IDEs will one day help beginners. Perhaps artificial intelligence modules will look at code and ask “Did you mean ‘Question’ and not "’question?” or “did you forget to declare this variable?” Or even “this variable is outside the scope of where it was declared.” This is the sort of hint that teachers give now.
All in all I think the answer is to make the tools more relatable to the people who use them. Teaching computers, which can be very difficult, seems, some days, to be a lot easier than teaching high school students.
2 comments:
Well, some tools that try to get more meaningful messages exits. For example - Thonny (IDE for Python) has "Assistant". For code
x = 1
y = y + 1
assistant "writes" (it is more nicely formatted...):
NameError: name 'y' is not defined
a.py, line 2
Python doesn't know what y stands for.
Did you actually mean string (text)?
If you didn't mean a variable but literal text "y", then surround it with quotes.
Did you forget to import it?
Some functions/variables need to be imported before they can be used.
Has Python executed the definition?
Don't forget that name becomes defined when corresponding definition ('=', 'def' or 'import') gets executed. If the definition comes later in code or is inside an if-statement, Python may not have executed it (yet).
Make sure Python arrives to the definition before it arrives to this line. When in doubt, use the debugger.
Warnings
May help you find the cause of the error.
a.py
Line 2 : Using variable 'y' before assignment
It looks like the local variable is accessed before its assignment.
It students did not make stupid errors what would we teachers do for fun? Make our own stupid errors? I am very experienced at that.
Post a Comment