Why is the method of creating a copy of the class?



  • ...... 
    PersonsExtracter personsExtracter = new PersonsExtracter().invoke(); 
    if (personsExtracter.wasError()) { 
        System.out.println("App was stopped"); 
        return;
    }
    ......
    

    You could explain in two words why you need a method. invoke() at the end of the facility new PersonsExtracter().invoke() or give a link where you could read it. Google, I didn't find a clear answer or I didn't ask the right question in the search. The right question is the right answer. To be honest, I haven't seen the code design so that the method is written at the end of the facility.



  • It's just that the method is being challenged. invoke() Class PersonsExtracterin which something is done, there may be some sort of thing to initiate something, design and other, and a reference to the same object (mostly).

    And since the method is not static, it can only be triggered by the creation of a copy that actually happens.

    I think it's a banal emulsion of the designer's work, that's instead of the method.

    class PersonsExtracter {
        public PersonsExtracter invoke() {
             // doing smth
            return this;
        }
    }
    

    It was possible to make a designer with the same job.

    class PersonsExtracter {
        PersonsExtracter() {
            // doing smth
        }
    }
    

    And for what reason the author decided to do so, or otherwise, you could ask him.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2