Skip to main content
Code Review

Return to Answer

replaced http://programmers.stackexchange.com/ with https://softwareengineering.stackexchange.com/
Source Link

This is a very nice way to do it yes.

A couple of comments:

  • The method performing the validation shouldn't be named isValid, because it does more than checking if the given IP adress is valid. If that were the case, it would only return a boolean true or false, saying whether IP given was valid or not. The method actually returns a status describing exactly what didn't validate. Consider renaming it to validate (a bit like the validate method of the Bean Validation API).
  • Beware that there can be IPv4 and IPv6 addresses. Your code only handles the former case.
  • If you use a switch to test the validation status, you could add a default case you could add a default case.

This is a very nice way to do it yes.

A couple of comments:

  • The method performing the validation shouldn't be named isValid, because it does more than checking if the given IP adress is valid. If that were the case, it would only return a boolean true or false, saying whether IP given was valid or not. The method actually returns a status describing exactly what didn't validate. Consider renaming it to validate (a bit like the validate method of the Bean Validation API).
  • Beware that there can be IPv4 and IPv6 addresses. Your code only handles the former case.
  • If you use a switch to test the validation status, you could add a default case.

This is a very nice way to do it yes.

A couple of comments:

  • The method performing the validation shouldn't be named isValid, because it does more than checking if the given IP adress is valid. If that were the case, it would only return a boolean true or false, saying whether IP given was valid or not. The method actually returns a status describing exactly what didn't validate. Consider renaming it to validate (a bit like the validate method of the Bean Validation API).
  • Beware that there can be IPv4 and IPv6 addresses. Your code only handles the former case.
  • If you use a switch to test the validation status, you could add a default case.
deleted 1 character in body
Source Link
Tunaki
  • 9.3k
  • 1
  • 31
  • 46

This is a very nice way to do it yes.

A couple of comments:

  • The method performing the validation shouldn't be named isValid, because it does more than checking if the given IP adress is valid. If that were the case, it would only return a boolean true or false, saying whether IP given was valid or not. The method actually returns a status describing exactly what didn't validate. Consider renaming it to validate (a bit like the [validate](http://docs.oracle.com/javaee/7 /api/javax/validation/Validator.html#validate-T-java.lang.Class...-)validate method of the Bean Validation API).
  • Beware that there can be IPv4 and IPv6 addresses. Your code only handles the former case.
  • If you use a switch to test the validation status, you could add a default case.

This is a very nice way to do it yes.

A couple of comments:

  • The method performing the validation shouldn't be named isValid, because it does more than checking if the given IP adress is valid. If that were the case, it would only return a boolean true or false, saying whether IP given was valid or not. The method actually returns a status describing exactly what didn't validate. Consider renaming it to validate (a bit like the [validate](http://docs.oracle.com/javaee/7 /api/javax/validation/Validator.html#validate-T-java.lang.Class...-) method of the Bean Validation API).
  • Beware that there can be IPv4 and IPv6 addresses. Your code only handles the former case.
  • If you use a switch to test the validation status, you could add a default case.

This is a very nice way to do it yes.

A couple of comments:

  • The method performing the validation shouldn't be named isValid, because it does more than checking if the given IP adress is valid. If that were the case, it would only return a boolean true or false, saying whether IP given was valid or not. The method actually returns a status describing exactly what didn't validate. Consider renaming it to validate (a bit like the validate method of the Bean Validation API).
  • Beware that there can be IPv4 and IPv6 addresses. Your code only handles the former case.
  • If you use a switch to test the validation status, you could add a default case.
Source Link
Tunaki
  • 9.3k
  • 1
  • 31
  • 46

This is a very nice way to do it yes.

A couple of comments:

  • The method performing the validation shouldn't be named isValid, because it does more than checking if the given IP adress is valid. If that were the case, it would only return a boolean true or false, saying whether IP given was valid or not. The method actually returns a status describing exactly what didn't validate. Consider renaming it to validate (a bit like the [validate](http://docs.oracle.com/javaee/7 /api/javax/validation/Validator.html#validate-T-java.lang.Class...-) method of the Bean Validation API).
  • Beware that there can be IPv4 and IPv6 addresses. Your code only handles the former case.
  • If you use a switch to test the validation status, you could add a default case.
lang-java

AltStyle によって変換されたページ (->オリジナル) /