It is never easy

Grading programming is a royal pain.  Why cannot my students give me the same answers for an assignment?  They have to get clever. They have to find some snippet on the internet that works maybe better than the solution in the book.  Or maybe worse but it still works. I give no restrictions regarding finding help on the internet. I want them to know about stackoverflow but I demand they understand what they use from online resources.

Here is an example.  The assignment is to write a program to capitalize the first letter in every word of a sentence.  The only real requirement is to use a sub-procedure. The first sample is the book solution and also the one I thought of.  A very traditional solution. The second sample is what most of my students turned in. I asked the first student to turn this in where he found it.  He pointed to a stackoverflow example that was sort of doing the same task. With the toTitleCase function. He just had to build the code around that function.  Of course that function spread like wildfire. One student that works in another room turned in a more traditional solution but it was still different from the book solution.

I like that the kids dig for solutions.  To me that is the whole idea of programming and computer science in general.  Find solution to problems you do not know the answer to by researching the internet.  It can lead to plagiarism but realistically, how many programmers in the real world come up with unique solutions?  I require that the kids explain their solution, they cannot just cut and paste. It just makes it a real pain to grade.

The only way I think I could possibly control what the solution is going to look like would be to put all sorts of restrictions and requirements on the methods to be used.  This is counter to my philosophy of teaching. I believe students should find solutions, not be told solutions. If this means I lose something to plagiarism, so be it. What I gain is worth it.

Book solution.

import java.util.Scanner;

public class Ch4_1Caps1

{

public static void main(String[] args)

{

  Scanner input = new Scanner(System.in);

  String line;

   System.out.println(“Enter a line of text.”);

   line = input.nextLine();

   System.out.println();

   System.out.println(“Capitalized version:”);

   printCapitalized( line );

}    

static void printCapitalized( String str )

{

     char ch;       

     char prevCh;   

     int i;         

     prevCh = ‘.’;  

     for ( i = 0;  i < str.length();  i++ )

     {

        ch = str.charAt(i);

        if ( Character.isLetter(ch)  && ! Character.isLetter(prevCh) )

           System.out.print( Character.toUpperCase(ch) );

        else

           System.out.print( ch );

        prevCh = ch;  

     }

     System.out.println();

}

}

 

Student solution.

 

import java.util.Scanner;

public class Ch4_1Caps2

{

public static String toTitleCase(String word)

{

return Character.toUpperCase(word.charAt(0)) + word.substring(1);

}

public static void main(String[] args)

{

Scanner s = new Scanner(System.in);

System.out.println(“What do you want uppercase?: “);

String phrase = s.nextLine();

sub(phrase);

}

public static void sub(String phrase)

{

String[] splitPhrase = phrase.split(” “);

String result = “”;

   for(String word: splitPhrase)

   {

       result += toTitleCase(word) + ” “;

   }

   System.out.println(result.trim());

}

}

 

Advertisements

2 Responses to “It is never easy”

  1. robinleeann Says:

    “I require that the kids explain their solution, they cannot just cut and paste. It just makes it a real pain to grade.” Sounds like you’re a great teacher right there. Even though it’s a bit more of a pain for you to grade, they seem to be doing more that will help them learn.

    I agree though. It’s never easy.

  2. Alfred Thompson Says:

    I figure that on average students come up with three different ways of doing things. Sometimes only two but sometime more than three. Sometimes I will take samples of the various solutions (with no names) and discuss them with the class. It gives me a chance to show that there is more than one way to do things AND to discuss optimization a little bit.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: