DEV Community

Cover image for Hey, I did a thing, you might like it! Java JSpecify Exercise
Ivan Juren
Ivan Juren

Posted on

Hey, I did a thing, you might like it! Java JSpecify Exercise

Learning by doing is the most durable kind of learning.

I’ve put together a small repo with ~20 classes, organised into easy, medium, and hard levels to introduce you to JSpecify.

So after reading the JSpecify docs, try to annotate given classes, specify the nulls, and get some real hands-on JSpecify experience.

I believe it’s really important to understand the “type” semantics shift — what @Nullable actually means. The generics really piqued my interest.

If you want a sneak peek at the kind of reasoning you’ll be doing, check out my other short read where I question one of my favourite patterns for dealing with nulls: Rethinking Optional<?>

Going from this:
Optionals way of handling nullability

To this:
JSpecify way of handling nullability

More concise and safer.


🔗 Repo: github.com/ivan-juren/jspecify-exercise

Can you see yourself using JSpecify in your projects?

Would love to hear what you think 👇

Top comments (1)

Collapse
 
roshan_sharma_7deae5e0742 profile image
roshan sharma

That’s awesome, man. Love how you turned JSpecify learning into a hands-on exercise, that’s the best way to really get it. The easy-to-hard setup is a nice touch too. Super practical project!