grpc-java-course
grpc-java-course copied to clipboard
Unnecessary try-catch instead of validation
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
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 :)