Skip to content

Commit

Permalink
Update tracks/java/exercises/gigasecond/mentoring.md
Browse files Browse the repository at this point in the history
Co-authored-by: Victor Goff <[email protected]>
  • Loading branch information
SleeplessByte and kotp authored Feb 16, 2024
1 parent 3dd09b9 commit 44e5047
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tracks/java/exercises/gigasecond/mentoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ A student can choose to compute the result for `getDate()` in the constructor. I

### Exception handling

`plusSeconds` can throw a `java.time.DateTimeException`. A student may choose to catch this exception in the constructor, but this results in `birthDateTime` being null, so the class won't have been instantiated properly. There's no sensible default value that be stored in `birthDateTime`. It's better to let the exception be thrown, failing fast, and let calling code deal with it.
`plusSeconds` can throw a `java.time.DateTimeException`.
A student may choose to catch this exception in the constructor, but this results in `birthDateTime` being null, so the class won't have been instantiated properly.
There's no sensible default value that be stored in `birthDateTime`.
It's better to let the exception be thrown, failing fast, and let calling code deal with it.

### Type safety

Expand Down

0 comments on commit 44e5047

Please sign in to comment.