Practice WOD: Web IO CountWords

Prior to starting this WOD, you might want to learn about the Apache HTTPComponents library. It provides useful classes to simplify Web-based interactions, as shown in the example on this page.

Instructions

  1. Start your timer.
  2. Create an Eclipse project called WebIO-CountWords.
  3. Enable Checkstyle for this project.
  4. Write a program that reads in the contents of the web page http://www.cnn.com, determines how many whitespace-delimited tokens (i.e. “words”) are in the file, and writes that integer to System.out.

When finished, stop your timer, and record how many minutes it took you to complete the WOD. Your program must satisfy our coding standards. You can copy/paste code from the prior program.

Rx: <15 min Av: 15-20 min Sd: 20-30 min DNF: 30+ min

Demonstration

Once you’ve finished doing the WOD a single time, watch me do it:

Standard WOD Caveats

You’ll learn significantly less from watching me solve the WOD if you haven’t attempted the WOD yourself first.

While it’s an achievement to finish the WOD no matter how long it takes, you might experience “diminishing returns” if you work longer than the DNF time. Thus, it might be strategic to stop working at the DNF time and watch my solution.

After watching my solution, I recommend that you repeat the WOD if you have not achieved at least Av performance. If so, be sure to:

Feel free to keep trying until you make Rx if that’s of interest to you.