Lots of developers write code like this
if(!StringUtil.isNullOrEmpty(notification.getNotificationTo()) { sendSMS(notification.getNotificationTo()); }
My notion is that this code keeps the developer safe. i.e it only sends the text message if number is present. It tries not to unnecessarily consume third party resources if number is not present. etc.
The problem with the code, however, is that it doesn't tell the system that something is wrong here while also not consume sms network calls.
if(StringUtil.isNullOrEmpty(notification.getNotificationTo())) { HIFILogger.logError("Could not send SMS in ABC class"); return; } sendSMS(notification.getNotificationTo());
The difference here is that, not only does this code return without executing sendSMS but also allows to throws an error to indicate in some log that there's a problem in a number being blank.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.