First kudos to your guide to better java. I like most parts of it.
In section Avoid Null I'd propose to not pass Optional parameters around because you cannot safely assume that those Optional objects aren't null itself. Instead I'd pass Bar directly and wrap itself as a nullable optional inside the constructor. That way you would prevent one possible NullPointerException during runtime.
I like this idea. However, I notice that I end up passing Optionals around sometimes just so I don't need to unwrap them. Maybe the fix here is to have both styles and comment on each?
First kudos to your guide to better java. I like most parts of it.
In section Avoid Null I'd propose to not pass Optional parameters around because you cannot safely assume that those Optional objects aren't null itself. Instead I'd pass Bar directly and wrap itself as a nullable optional inside the constructor. That way you would prevent one possible
NullPointerException
during runtime.