dashakrolik / surf-forecast-backend

0 stars 0 forks source link

Returning null #12

Open driversti opened 4 years ago

driversti commented 4 years ago

https://github.com/dashakrolik/surf-forecast-backend/blob/0b46b33ff238589a958c0a0eea8954450bb063a1/src/main/java/com/ordina/surfforecast/service/BeachService.java#L85

Returning null is a bad practice.

dashakrolik commented 4 years ago

Thanks! It's my first Java app. What would you say is better practice?

Sometimes I get a null pointer exception when calling getAllBeaches, I wonder if this might be reason...

driversti commented 4 years ago

Of course. It would be better to operate on the object when you're sure that it exists.