grpc-java-course icon indicating copy to clipboard operation
grpc-java-course copied to clipboard

Unnecessary try-catch instead of validation

Open AlexBen opened this issue 5 years ago • 1 comments

Hello Stephane, I'm taking your course right now, and during it just found the approach you use, which in my opinion could be improved. I understand that the course is not about "good practices" or "java coding", but since the students could refer to this code, it makes sense to use best practices.

In this case, ObjectId has a static method #isValid, and we can make this check (with returning INVALID_ARGUMENT status) instead of naive try-catch.

https://github.com/simplesteph/grpc-java-course/blob/f4352f6460b76a869b28bafbf9fdfc07f2c4b900/src/main/java/com/github/simplesteph/grpc/blog/server/BlogServiceImpl.java#L64

AlexBen avatar Apr 04 '20 19:04 AlexBen

hey thanks for the feedback! I'm certain the code could be improved here and there, but I can't change it right now as this wouldn't match the video recording. Hope you understand :)

simplesteph avatar Apr 05 '20 07:04 simplesteph