8th Light Rubber Duck
8th Light Rubber Duck
How’s my coding? Just ducky.

Alternatively titled:

  • Oh, you stuck?!
  • Software developers hate him…
  • The brain unlocking system used by Bill Gates that Warren Buffet doesn’t want you to know about…
  • One simple trick to get rid of acne… (wait a minute)

Oh, you get it. So maybe at some point in your programming career (or another career? This process works for so many careers), you have found yourself stuck. No? Well, thanks for getting this far in the article, but there is nothing for you here. …

As I moved into my first projects with exception handling I had a conceptual problem with when I should be using throws and when I should be using a try/catch block. Then I had the full “Ohhhhhhhhhhhhh” moment while I was reading the chapter on exception handling in “Head First Java”.

Here is the TL;DR right up front:

  • If a method is considered risky (it might not execute properly due to exceptional circumstances) it must declare that it throws an exception.
  • The risky method that is called will throw the exception.
  • The method that calls the risky method will catch

As I progress through my software crafter apprenticeship at 8th Light I’ve been given a series of slightly more complex projects to work on in Java. I’ve been using Gradle for my build automation and IntelliJ as my IDE. When you create a new project you should have a path directory that looks similar (identical) to this:

Standard Gradle directory structure created for a new project.

For smaller projects this is fine, all of your classes will go in src/main/java and your tests will go into src/test/java. …

Charles Kubiak

Software Crafter @8thLight. Chicago

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store