Ellen Spertus
10/15/2022, 4:40 AM!!
on assignments, or they would lose points (and their code would potentially throw NPEs).
A few hours later, a fellow professor (not of my course) posted to an internal Team:
Are other people getting anxious questions about details in assignments? "Professor, I put two exclamation points after 'Hello world!', will you take off points for that?"I let him know that, indeed, I would take points off for having two exclamation points in an assignment.
rtsketo
10/15/2022, 5:24 AMCicero
10/15/2022, 11:52 AMIgnat Beresnev
10/15/2022, 12:31 PM!!
is great 👍
If you really need to assert nullability, using ?: throw SomeException("clear explanation")
or something similar instead would be so much more productive whenever it gets thrownEllen Spertus
10/15/2022, 3:58 PMDavide Giuseppe Farella
10/15/2022, 4:19 PM!!
Maybe your code will change to actually make that field nullable, so having a require/checkNotNull
with an appropriate message will surely throw an exception anyways, but at least it would be easier to spot.andylamax
10/16/2022, 4:55 AMRob Elliot
10/17/2022, 7:16 AMreturning
to get the generated ID back. It's a call that I know can never return null
- if the insert succeeds I'll get the row back, if it fails an exception will be thrown. As it happens the jOOQ fetchOne
method that returns the row is annotated @Nullable
.
My current feeling is that adding the noise of a ?: throw Impossible("explanation")
is worse than a simple !!
in that case.Rob Elliot
10/17/2022, 7:54 AMfun <R: Record> InsertResultStep<R>.fetchExactlyOne(): R =
fetchOne() ?: throw NoSuchElementException("fetchOne returned null - no rows matched query")
Then it's only messy once and there's a clear explanation if somehow it did happen.Davide Giuseppe Farella
10/18/2022, 12:17 PMRob Elliot
10/18/2022, 12:22 PMDavide Giuseppe Farella
10/18/2022, 12:23 PM