Download SIGCSE presentation

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Falcon (programming language) wikipedia , lookup

Programming language wikipedia , lookup

Logic programming wikipedia , lookup

Functional programming wikipedia , lookup

Go (programming language) wikipedia , lookup

Scala (programming language) wikipedia , lookup

Reactive programming wikipedia , lookup

Object-oriented programming wikipedia , lookup

Error detection and correction wikipedia , lookup

Structured programming wikipedia , lookup

Java (programming language) wikipedia , lookup

Java performance wikipedia , lookup

C Sharp (programming language) wikipedia , lookup

Transcript
Identifying and Correcting
Java Programming Errors
for Introductory Computer
Science Students
Maria Hristova, Ananya Misra,Megan Rutter
Rebecca Mercuri, Ph.D.
Mathematics and Computer Science Department
Bryn Mawr College
BRYN MAWR
Purpose of the Study
• Beginning programmers often find it
difficult to understand some of the
linguistic constructs in the C/C++/Java
family of languages.
• This results in certain common errors
during the coding process.
• Students may be further confused from
cryptic diagnostic messages issued by
the compiler.
• We wanted to study this problem using
Java in the CS1 environment.
Java Programming Errors
SIGCSE 2003
BRYN MAWR
Project Funding
• Support was provided for 3 Bryn Mawr
Math/CS students (2 Seniors and 1 Junior)
to perform this research with their Professor.
• Funding was received from the
Collaborative Research Experience for
Women (CRE-W) program, part of the
Computer Research Association (CRA).
• The students received academic credit for
this project.
Java Programming Errors
SIGCSE 2003
BRYN MAWR
Project Goal
The creation of an educational tool that
would help students identify and fix
their programming errors, and also
teach them how to avoid making these
coding mistakes again.
Java Programming Errors
SIGCSE 2003
BRYN MAWR
Project Phases
I: Identification of Errors
Java professors, TAs, and students were
surveyed from 50 schools.
They were asked to identify the most common
programming errors made by introductory
students, as well as the hardest ones to find,
after compilation reported their mistakes.
62 errors were identified, 20 deemed essential to
the project.
Java Programming Errors
SIGCSE 2003
BRYN MAWR
Project Phases
I: Identification of Errors
II: Choice of Implementation
Existing educational tools were examined:
TA Online, DrScheme, BlueJ
Intention was to create a tool that could be used
in the early stages of learning programming.
The tool should do a better job generating
understandable error messages than
existing compilers, and provide suggestions
regarding how to fix the code.
Java Programming Errors
SIGCSE 2003
BRYN MAWR
Project Phases
I: Identification of Errors
II: Choice of Implementation
III: Implementation
“Expresso” -- a multi-pass Java pre-processor,
written in C++:
– strips comments, retains line numbering
– removes whitespace and tokenizes the file
– detects and reports mistakes in additional
passes
Created a test suite of short programs to exercise
the individual errors that Expresso could
identify.
Java Programming Errors
SIGCSE 2003
BRYN MAWR
Project Phases
I: Identification of Errors
II: Choice of Implementation
III: Implementation
IV: Evaluation
TAs for the Fall’02 CS1 Java course were provided
with copies of Expresso for experimental use.
More extensive testing in the programming
laboratory setting will be explored.
Java Programming Errors
SIGCSE 2003
BRYN MAWR
Types of Errors
Implemented:
• Syntax - spelling, punctuation and order of words in
the program
• Semantic - likely to ensue from a mistaken idea of
how the language interprets certain instructions
• Logic - tend to arise from fallacious thinking by the
programmer rather than from language peculiarities
Unimplemented:
– Already identified well by the compiler
– Don’t apply to introductory students
– Can’t be checked by preprocessor
Java Programming Errors
SIGCSE 2003
BRYN MAWR
Syntax Errors
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
= versus ==
== versus .equals
mismatching, miscounting and misuse of ( ), [ ], { }, “ “, ‘ ‘
&& versus & and || versus |
semicolon after if/for/while test
wrong separators in for loops
if followed by { instead of (
keywords used as method or variable names
invoking methods with wrong arguments
forgetting parentheses after method call
incorrect semicolon at end of method header
leaving space after period when calling method
=< and => incorrect operators
Java Programming Errors
SIGCSE 2003
BRYN MAWR
Semantic Errors
1.
invoking class method on object
Java Programming Errors
SIGCSE 2003
BRYN MAWR
Logic Errors
1.
2.
3.
4.
5.
6.
improper casting
invoking a non-void method in a statement that
requires a return value
flow reaches end of non-void method
confusion between declared and passed
parameters
incompatibility between declared return type of a
method and its invocation
class declared abstract because of missing
function
Java Programming Errors
SIGCSE 2003
BRYN MAWR
Sample Run Code
// sample run
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public int computeSum(int apple, int sauce){
int appleSauce;
if (apple = sauce){
appleSauce= apple + sauce;
}
else if (apple > sauce);{
appleSauce == apple - sauce;
}
else{
appleSauce = 49;
}
return appleSauce;
}
public class SampleRun extends Applet implements ActionListener {
Label sampleLabel = new Label("Sample Label", Label.LEFT);
Panel samplePanel = new Panel();
public void init();{
samplePanel.setLayout(new FlowLayout(FlowLayout.LEFT));
samplePanel.add(sampleLabel);
add(samplePanel);
repaint();
}
}
public void paint(Graphics g){
char bear = 'p';
String cheese = "appleSauce";
computeSum(cheese, bear);
}
Java Programming Errors
SIGCSE 2003
BRYN MAWR
Sample Run Output
Java Programming Errors
SIGCSE 2003
BRYN MAWR
Demonstration
Java Programming Errors
SIGCSE 2003
BRYN MAWR
Results
• The list of common errors and the test suite can
be useful educational tools for CS1 students.
• The Expresso project was a tremendous
learning experience for the students who
performed the research.
• Further assessment of Expresso in classroom
and laboratory environments will help improve
and evaluate the tool’s utility.
Java Programming Errors
SIGCSE 2003
BRYN MAWR
For Further Information
Dr. Rebecca Mercuri
Bryn Mawr College
[email protected]
http://mainline.brynmawr.edu/~rmercuri
Java Programming Errors
SIGCSE 2003
BRYN MAWR
Java Programming Errors
SIGCSE 2003
BRYN MAWR
Theoretical Framework
• Pea and Kurland – Cognitive Aspect
– Define programming as both a mental mode and a skill like reading
– Define the need for a tight bond between an instructional and
programming environment
• Du Boulay – Language-Independent Aspect
– Defines the five language-independent areas of difficulty and three
kinds of corresponding mistakes
• Fleury – Java Aspect
– Creates a list of the four most common “student-constructed rules”
in Java
– Explores how students understand Java code and what their
misconceptions might be
Java Programming Errors
SIGCSE 2003
BRYN MAWR
Our aim in this project was to create an
educational tool that would not only help
students identify and fix their existing
programming errors, but also help prevent
them from making them again in the future.
We accomplished this by compiling a list of
common Java programming errors made
by introductory students, designing and
coding a program that identifies these
mistakes and returns instructive error
messages, and testing our program on our
test suite.
We believe that our resulting project will
prove to be a very useful tool for future
introductory Computer Science students.
Java Programming Errors
SIGCSE 2003
BRYN MAWR