Uploaded image for project: 'OpenNLP'
  1. OpenNLP
  2. OPENNLP-1044

Add validate() which checks validity of parameters in the process of the framework

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.8.0
    • Component/s: None
    • Labels:
      None

      Description

      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:

      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();
        }
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                koji Koji Sekiguchi
                Reporter:
                koji Koji Sekiguchi
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: