Arjen: A Tool to Identify Common Programming Errors

(c) Warren Toomey (wtoomey at staff.bond.edu.au) and Jon Gjengset
GPL3 license.

Introduction

Arjen is a tool to find common programming errors that novice programmers make, and to report these errors back in a descriptive way that reiterates the core concepts of programming, and also gives advice that the student can follow to fix the problem.

At present, Arjen is in the prototype stage. I am keen to collaborate with other teachers/researchers to try this tool, or its successor, on a large population of students, to quantify the benefit that Arjen gives to their learning.

You can download Arjen here: arjen_1.0.tar.gz.

Operation

Arjen runs as a web service, with a Bluej plugin as the client. Once the Arjen extension has been added to Bluej, a student can right-click on a class file in the main project window, and choose to "Check with Arjen". The file's source code is sent to the Arjen service, which identifies any common errors, and returns a report to the student. This appears as a pop-up window which the student can read.

Here are some example screenshots of the request to Arjen and its report.

Requirements

As Arjen is a web-service, you will need a web server like Apache that can support CGI. The Arjen service is written in Perl, so you will also need Perl installed along with these modules: CGI, Cwd, DBI, Data::Dumper, Digest::SHA1, File::Basename, File::Temp, JSON, Parse::Yapp and XML::Writer. If you are running Ubuntu, then these are the extra packages you need:
libparse-yapp-perl
libclass-dbi-perl
libclass-dbi-sqlite-perl
libdbi-perl
libdigest-sha1-perl
libjson-perl
libjson-xs-perl
libxml-writer-perl
sqlite3
apache2
default-jdk
You'll also need sqlite3 as the database component, and a Java development environment (JDK) on the server side. If there is anything else that I've missed, please let me know.

Installation and Configuration

Unpack the Arjen tarball somewhere on the server where you are happy for it to stay permanently. The directory and subdirectories need to be readable by the web server.

Run the make command. This will set up the initial database, build the Java parser and create the Bluej extension jar file.

Before you set up the Arjen web service, you can quickly test to see if Arjen works as-is. At the command-line, run the command:

	./main.pl examples/Equals.java
This will check the file examples/Equals.java for errors, and you should see two error descriptions output on the command-line:
	Line 00018: Not a Statement
	Line 00020: Assignment in IF Condition
If this is produced, then all the dependencies are met. If not, you will probably get some warnings about missing modules, so use this information to find and fix them.

Now we move on to the setup of the web service. Copy the file cgi/xml.cgi into your web server's CGI directory. You may want to rename this to a more sensible name like arjen.cgi or arjen.pl. Make the file executable by the web server. Edit this file so that the line:

	use lib '..';
names the directory where you unpacked Arjen, e.g.
	use lib '/usr/local/arjen';
At the command line, you should be able to run this script, and if all the permissions and dependencies are correct, you should see something like this:
	Content-Type: text/xml; charset=ISO-8859-1

	Use of uninitialized value $Lexer::IN in  at /usr/local/arjen/backends/yacc/Lexer.pm line 95.
	Use of uninitialized value $Lexer::IN in  at /usr/local/arjen/backends/yacc/Lexer.pm line 95.
	Use of uninitialized value $source in print at /usr/local/arjen/backends/javac.pm line 25.
	Use of uninitialized value $source in split at /usr/local/arjen/backends/miscsyntax.pm line 39.
The Arjen web service should now be set up and running. You need to determine the URL for this service. If you named the script arjen.pl, for example, then it will probably be something like http://your.server.org/cgi-bin/arjen.pl

You now need to change the Bluej extension source code so that your students access your Arjen server when they use Arjen. Edit the file bluej/ArjenExtension.java. Find the line that says:

   public static final String URL_DEFAULT = "http://your.webserver.edu/cgi-bin/arjen.pl";
and change that URL to the URL for your Arjen web service. Save this file, and re-run the make command at the top of the Arjen directory. This will recompile the Bluej extension code and rebuild the jar file. Take the resulting jar file, bluej/arjen.jar, and install it into your Bluej extensions area. This is highly dependent on what platform you are running, and you should consult the Bluej documentation.

Fingers crossed, you should now be able to run Bluej, and in a project you can right-click on a class file and check it with Arjen. The first time, you may be asked to choose a username. Choose anything textual: it doesn't really matter what you choose, as Arjen hashes it anyway so that students' identities are not stored in the results.

The Database

In the Arjen directory there is an Sqlite database called arjen.db which stores the known errors, and also logs the invocations of Arjen and the errors found. The database contains the following tables:

Queries, Questions etc.

If you have any questions about configuring or using Arjen, please contact me on my e-mail address. The most likely problems are getting the Perl dependencies correct, and getting the ownerships and permissions on files and directories correctly set up for the web server.

Many thanks for your interest in Arjen!

Warren Toomey, July 2011.