Archive for January, 2019

“Crazy code” posted

Thursday, January 31st, 2019

I’ve posted the and files from today’s in-class activity to Canvas (under “Files”) so you can run it and insert .println()‘s if you wish.

Please do not post any part of this to the Internet!

Also, if you have questions about any part of the activity, please feel free to drop by office hours or ask me over email! This is critical stuff to get right.

Stephen’s Star Wars solution posted

Wednesday, January 30th, 2019

If you got wrapped around the axle on homework #1, and/or are curious as to how I did it, feel free to look at my and in the “Files” tab of Canvas.

Please DO NOT post these files to the Internet anywhere!

Quiz #1 posted!

Wednesday, January 30th, 2019

Quiz #1 is now available in Canvas, and may be taken any time from now up until Chinese New Year (Tuesday, Feb 5th at midnight).

The quiz is open-book, open-notes, closed-Java, closed-other-Websites, and timed at 40 minutes. It must be taken completely on your own, without any help from others.

Responsive reading #2 posted!

Wednesday, January 30th, 2019

Responsive reading #2 has been posted, and is due next Thursday at midnight. It’s a great reading: have fun with it!

Properly indenting your code

Saturday, January 26th, 2019

I saw a student’s code today that was entirely flush-left on the page, rather than being indented according to the actual structure of the Java program. Perhaps others are doing this as well. It could be because NetBeans/Eclipse/IntelliJ auto-indented everything for you as you typed, which may have had the unfortunate side-effect of not training you to properly recognize and carry out correct indentation.

This is actually really important. If you can’t readily see what’s inside a loop as opposed to coming after it, or where each method begins and ends at a glance, you’ll make lots of misdiagnoses when trying to debug your program.

Life hack for the day: you can auto-indent all your code in vim with the following sequence of commands (while in command mode; press ESC if you are in insert mode to go back to command mode):


This sequence of characters means the following:

  1. gg (this goes to the top of the file)
  2. V (this puts you in visual mode)
  3. G (this goes to the end of the file, thus highlighting the whole thing)
  4. = (this auto-indents everything highlighted)

Save your file with :w after doing this, of course, and from that point on, properly indent your new code.

Office hours switch

Friday, January 25th, 2019

Due to uninteresting reasons, I’m swapping my previously announced Tuesday and Thursday office hours times for the rest of the semester. Here’s the new office hours.

Fixing the Black Screen Of Death (BSOD)

Friday, January 25th, 2019

Reminder: if you get the scary screen when you try to vim your file:

Found a swap file by the name ""
          owned by: stephen   dated: Fri Jan 25 12:20:48 2019
         file name: /tmp/
          modified: no
         user name: stephen   host name: tatooine
        process ID: 3037 (still running)
While opening file ""

(1) Another program may be editing the same file.  If this is the case,
    be careful not to end up with two different instances of the same
    file when making changes.  Quit, or continue with caution.
(2) An edit session for this file crashed.
    If this is the case, use ":recover" or "vim -r"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file ""
    to avoid this message.

Swap file "" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort: 

the way to fix it is simply to remove the swap file. The command is:

$ rm


Thursday, January 24th, 2019

FYI, by end of this week, you should have read chapters 1 through 3 of Blueprints.

Happy reading!

Car example posted

Tuesday, January 22nd, 2019

This class will use the following github repo for example code:

There are two ways you can access the code:

  1. Browse it on the github website. This is good for quick inspections.
  2. Clone the repo to your GC instance, which will (1) produce a copy of the entire contents for you, and (2) “connect” your GC directory so that any time I add to the class github repo, you can simply “git pull” to update with the most recent contents.

    To do this, type this in your GC instance:

    $ git clone

    which will create a cpsc240s19 directory in your current directory, with all the contents.

Currently, the only code in this repo is the Car example from class today.

git setup

Monday, January 21st, 2019

Apparently I forgot a step in the instructions for getting git setup, which is that before you can use it to do anything meaningful, you have to configure two settings. Luckily, git itself tells you exactly what to do when you try it. Simply type these two commands:

      $ git config --global ""
      $ git config --global "Your Name"

(Put the right stuff instead of the placeholders, of course.) And then it will all work!