You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@opennlp.apache.org by "Koji Sekiguchi (JIRA)" <ji...@apache.org> on 2017/04/24 04:55:04 UTC

[jira] [Created] (OPENNLP-1044) Add validate() which checks validity of parameters in the process of the framework

Koji Sekiguchi created OPENNLP-1044:
---------------------------------------

             Summary: Add validate() which checks validity of parameters in the process of the framework
                 Key: OPENNLP-1044
                 URL: https://issues.apache.org/jira/browse/OPENNLP-1044
             Project: OpenNLP
          Issue Type: Improvement
            Reporter: Koji Sekiguchi
            Priority: Minor


When I worked on OPENNLP-1039, I saw the client codes throw IllegalArgumentException when isValid() returns false, but I think such kind of methods should throw the Exception by themselves and the timing of use should be controlled by the framework.

So it should look like:

{code}
public abstract class AbstractTrainer {
  @Depracated
  public boolean isValid() { ... }

  // if the subclass overrides this, it should call super.validate();
  public void validate() throws IllegalArgumentException {
    // default implementation here
  }

  // this is the controller of the flow of training...
  public final void train() {
    // initializing 
    init();

    // validating parameters
    validate();
  }
}
{code}




--
This message was sent by Atlassian JIRA
(v6.3.15#6346)