2 added 10 characters in body
source | link

I would try to focus in on the kinds of errors that beginner programmers get stuck on, to imitate as closely as possible the kind of situation that they would want a debugger for. So, I might code this method, which contains exactly the sort of subtle mistake 101 students regularly make, right in front of them:

public static boolean compare (String a, String b){
    boolean same  = true;
    for(int k = 0; k < a.length(); k++){
        if (a.charAt(k) != b.charAt(k))
            same = false;
    }
    return same;
}

...If someone starts to mention some errors, pretend that you are simply too focused on coding to deal with them right now. Please don't interrupt! We are creating very important code right now, and it takes concentration!

I would then follow up by putting in some tests, one at a time. Have a big reaction when the first two tests go well, appear to get a little flustered by the third test, and become quite upset bywhen the fourth test crashes.

public static void main(String[] args) {
    System.out.println(compare("",""));
    System.out.println(compare("cat","dog"));
    System.out.println(compare("car","carport"));
    System.out.println(compare("fortress","for"));
}

Then I would announce that, as a mistake has clearly been made, and as there is clearly no one in the room even remotely smart enough to figure out what it is, this is now a moment to go to the debugger.

The theatrics are a bit of my own manner in the classroom, but also serve a purpose here. I want to get around the handful of quicker students who will spot the error right away with a bit of a wink that lets them know that they are perfectly smart, but not to ruin this for everyone else. I want to keep them quiet long enough to let us get through the debugging process together.

Afterwards, I would acknowledge that anyone who saw the error was perfectly clever, but that the debugger is important because they will, without any doubt, encounter bugs that they will have trouble locating. The debugger is one important part of the toolset that they will need to right the ship when it starts to go askew in the future.

I would try to focus in on the kinds of errors that beginner programmers get stuck on, to imitate as closely as possible the kind of situation that they would want a debugger for. So, I might code this method, which contains exactly the sort of subtle mistake 101 students regularly make, right in front of them:

public static boolean compare (String a, String b){
    boolean same  = true;
    for(int k = 0; k < a.length(); k++){
        if (a.charAt(k) != b.charAt(k))
            same = false;
    }
    return same;
}

...If someone starts to mention some errors, pretend that you are simply too focused on coding to deal with them right now. Please don't interrupt! We are creating very important code right now, and it takes concentration!

I would then follow up by putting in some tests, one at a time. Have a big reaction when the first two tests go well, appear to get a little flustered by the third test, and become quite upset by the fourth test.

public static void main(String[] args) {
    System.out.println(compare("",""));
    System.out.println(compare("cat","dog"));
    System.out.println(compare("car","carport"));
    System.out.println(compare("fortress","for"));
}

Then I would announce that, as a mistake has clearly been made, and as there is clearly no one in the room even remotely smart enough to figure out what it is, this is now a moment to go to the debugger.

The theatrics are a bit of my own manner in the classroom, but also serve a purpose here. I want to get around the handful of quicker students who will spot the error right away with a bit of a wink that lets them know that they are perfectly smart, but not to ruin this for everyone else. I want to keep them quiet long enough to let us get through the debugging process together.

Afterwards, I would acknowledge that anyone who saw the error was perfectly clever, but that the debugger is important because they will, without any doubt, encounter bugs that they will have trouble locating. The debugger is one important part of the toolset that they will need to right the ship when it starts to go askew in the future.

I would try to focus in on the kinds of errors that beginner programmers get stuck on, to imitate as closely as possible the kind of situation that they would want a debugger for. So, I might code this method, which contains exactly the sort of subtle mistake 101 students regularly make, right in front of them:

public static boolean compare (String a, String b){
    boolean same  = true;
    for(int k = 0; k < a.length(); k++){
        if (a.charAt(k) != b.charAt(k))
            same = false;
    }
    return same;
}

...If someone starts to mention some errors, pretend that you are simply too focused on coding to deal with them right now. Please don't interrupt! We are creating very important code right now, and it takes concentration!

I would then follow up by putting in some tests, one at a time. Have a big reaction when the first two tests go well, appear to get a little flustered by the third test, and become quite upset when the fourth test crashes.

public static void main(String[] args) {
    System.out.println(compare("",""));
    System.out.println(compare("cat","dog"));
    System.out.println(compare("car","carport"));
    System.out.println(compare("fortress","for"));
}

Then I would announce that, as a mistake has clearly been made, and as there is clearly no one in the room even remotely smart enough to figure out what it is, this is now a moment to go to the debugger.

The theatrics are a bit of my own manner in the classroom, but also serve a purpose here. I want to get around the handful of quicker students who will spot the error right away with a bit of a wink that lets them know that they are perfectly smart, but not to ruin this for everyone else. I want to keep them quiet long enough to let us get through the debugging process together.

Afterwards, I would acknowledge that anyone who saw the error was perfectly clever, but that the debugger is important because they will, without any doubt, encounter bugs that they will have trouble locating. The debugger is one important part of the toolset that they will need to right the ship when it starts to go askew in the future.

1
source | link

I would try to focus in on the kinds of errors that beginner programmers get stuck on, to imitate as closely as possible the kind of situation that they would want a debugger for. So, I might code this method, which contains exactly the sort of subtle mistake 101 students regularly make, right in front of them:

public static boolean compare (String a, String b){
    boolean same  = true;
    for(int k = 0; k < a.length(); k++){
        if (a.charAt(k) != b.charAt(k))
            same = false;
    }
    return same;
}

...If someone starts to mention some errors, pretend that you are simply too focused on coding to deal with them right now. Please don't interrupt! We are creating very important code right now, and it takes concentration!

I would then follow up by putting in some tests, one at a time. Have a big reaction when the first two tests go well, appear to get a little flustered by the third test, and become quite upset by the fourth test.

public static void main(String[] args) {
    System.out.println(compare("",""));
    System.out.println(compare("cat","dog"));
    System.out.println(compare("car","carport"));
    System.out.println(compare("fortress","for"));
}

Then I would announce that, as a mistake has clearly been made, and as there is clearly no one in the room even remotely smart enough to figure out what it is, this is now a moment to go to the debugger.

The theatrics are a bit of my own manner in the classroom, but also serve a purpose here. I want to get around the handful of quicker students who will spot the error right away with a bit of a wink that lets them know that they are perfectly smart, but not to ruin this for everyone else. I want to keep them quiet long enough to let us get through the debugging process together.

Afterwards, I would acknowledge that anyone who saw the error was perfectly clever, but that the debugger is important because they will, without any doubt, encounter bugs that they will have trouble locating. The debugger is one important part of the toolset that they will need to right the ship when it starts to go askew in the future.