6
$\begingroup$

Here is the essential parts of a (HS) Junior level question from one of our (Canadian) national computing challenges. (http://www.cemc.uwaterloo.ca/contests/computing/2017/stage%201/juniorEF.pdf)

Problem start

Input Specification:
The first line of input contains the integer x (−1000 ≤ x ≤ 1000; x != 0). The second line of input contains the integer y (−1000 ≤ y ≤ 1000; y != 0).

Output Specification
Output the quadrant number (1, 2, 3 or 4) for a specific x,y coordinate.

end

I have long suspected a difference in the outcome between objects-early and objects-late. For instance, a student who was given an objects-early approach might create code like this:

public class Point
{
    public Point( int x, int y)
    {
        this.x = x;
        this.y = y;
    }

    public int getQuadrant()
    {
        if(x>0 && y>0) return 1;
        if(x>0 && y<0) return 4;
        if(x<0 && y>0) return 2;
        if(x<0 && y<0) return 3;
        return 0;   // origin or no quadrant
    }

    private int x = 0;
    private int y = 0;
}

Whereas a student who was given an objects-late approach might create code more like so:

public int determineQuadrant1( int x, int y )
{
        if(x>0 && y>0) return 1;
        if(x>0 && y<0) return 4;
        if(x<0 && y>0) return 2;
        if(x<0 && y<0) return 3;
        return 0;   // origin or no quadrant
}

And similarly later in the same challenge students were asked if there could arrive at a destination (coordinate) using an exact number of moves (energy) and I noticed these types of solutions:

public class Point {
      public int distanceTo( Point p )
      { return | x – p.x | + | y – p.y | ; }    // math notation used }

While Late Objects students continued to approach the solution as functions with:

int getDistance( int x1, int y1, int x2, int y2 )
{ /* same math */ }

What I think I am seeing is a preference for Early Object students to employ objects and services in their solutions from the start, while Late Object students kind of ease into it if at all. I have additional examples from questions later in the challenge that seem to support this.

Is there evidence, either published or anecdotal, that I am correct? Do we know that the order of instruction matters here?

$\endgroup$
  • $\begingroup$ I have other more substantial examples I can share/post if required for clarification. $\endgroup$ – Mr Bradley Feb 8 '18 at 16:52
  • $\begingroup$ Say more about what you mean by "outcomes". The code may be different, but is either necessarily to be preferred, especially in the context of a programming contest? $\endgroup$ – Buffy Feb 8 '18 at 16:57
  • $\begingroup$ Is x! = 0 supposed to be x != 0? $\endgroup$ – candied_orange Feb 8 '18 at 17:30
  • $\begingroup$ @CandiedOrange yes it should read x != 0 $\endgroup$ – Mr Bradley Feb 8 '18 at 17:40
  • $\begingroup$ Fixed, I hope. MathJax was formatting oddly. $\endgroup$ – Buffy Feb 8 '18 at 17:46
1
$\begingroup$

tl;dr/ Students tend to do what they have the most practice doing. But timed contests can advantage/disadvantage some students independent of skill and background.

I have to admit I'm not a big fan of timed contests for programming. I don't know if that is the situation here, of course. The problem is that they favor quick thinking over deep thinking. If you don't have time to get something for every question your score likely suffers even if your solutions to the ones you work on are brilliant.

My advice to a student taking such a challenge would be to get something for every question.

That said, I would expect that students who have seen a lot of OO, and, in particular, have written a lot of classes themselves would naturally (and quickly) put down a class framework and then write methods. Less likely (given time constraints) would they do a problem decomposition into appropriate helper objects and composition of objects to solve any problem. It just takes too long, unless they have an IDE that will produce class/method templates at a click, or use JUnit or similar to build the application scaffolding for a given test.

Likewise, I'd expect that a student with little experience in creating classes would be more likely to just write functions, even if they had seen objects/classes. In a way, assuming that the test judging criteria allow either approach, these students may have a bit of a time advantage since there is less to type.

The psychological effect here is that you tend to do what you have the most practice doing. So Object-Early students automatically start by writing class ..... and Object-Late students may not. But there is little time for reflection on the quality of your overall structure in any case. And likely none for refactoring.

A possible countering psychological effect, since the competitions/challenges take place during the school year is that there is a tendency to repeat what you have most recently been focused on, being fresh in your mind, though less settled.

My bottom line, however is that programming isn't best tested in a timed environment, especially when the questions can be tricky in some sense, where you get an advantage, perhaps serendipitously, if you just think of the trick involved or have seen it before. Some students (my history says I'm one of them) is disadvantaged in this situation.

On the other hand, I can write code very quickly (hundreds of correct lines of code per day) with good tools and practices, including test-driven development with a good IDE (Eclipse). But if you give me a variation of NIM or some other mathematical puzzle, I'll stare at it for too long.


I also teach objects from the start (before if and while) since I value large scale structure over small. That is, providing a solid framework for the smaller scale issues.

$\endgroup$
  • 1
    $\begingroup$ "You tend to do what you have most practice doing." Indeed. $\endgroup$ – Mr Bradley Feb 8 '18 at 18:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.