11 Jan 2011, 14:44
Paper_02_80x80_pragsmall

Thomas Costick (8 posts)

With stub methods allowing earlier testing of the app in Chapter 4, I was able to see the D-pad selection of cells in section 4.3.

It struck me that wrapping the cursor around the edges of the grid would improve usability. Here’s the two-line change in PuzzleView.select()

Before:


    selX = Math.min(Math.max(x, 0), 8);
    selY = Math.min(Math.max(y, 0), 8);

After:


    selX = (x+9) % 9;
    selY = (y+9) % 9;

This shows the value of incremental testing. If I had not tried this early on, I may not have had time (or the enthusiasm) to change it at a later stage.

  You must be logged in to comment