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

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 1.8.0
    • None
    • 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

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

              Dates

                Created:
                Updated:
                Resolved: