3 ms·
am I reading this right? it seems number 3 is suggesting I accept Optional as function/method parameters? That is an anti-pattern if ever there was one, and it
by amarant 8y ago
am I reading this right? it seems number 3 is suggesting I accept Optional as function/method parameters? That is an anti-pattern if ever there was one, and it also adds another layer of if's instead of removing it. an empty collection is fine, but if I accept an optional, I need to first check that the optional isn't null (because it can be!) and if its not, check if the optional has a value(basically another nullcheck, jay!). optionals should only ever be used as a return-type. I hear a lot of people say that they should be used as parameters to indicate that one parameter is not necessary, but that's what overloads are for!