title: Java Builder pattern
body: <p>I recently wrote a builder class and noticed that the standard seems to be as follows</p>
  
  <pre><code>public class PersonBuilder {
      private String firstName;
      private String lastName;
  
      public PersonBuilder withFirstName(String firstName) {
          this.firstName = firstName;
          return this;
      }
  
      public PersonBuilder withLastName(String lastName) {
          this.lastName = lastName;
          return this;
      }
  
      public Person build() {
          return new Person(this);
      }
  }
  </code></pre>
  
  <p>Is there any disadvantage to, instead, doing the following</p>
  
  <pre><code>public class PersonBuilder {
      private Person person;
  
      public PersonBuilder withFirstName(String firstName) {
          person.setFirstName(firstName);
          return this;
      }
  
      public PersonBuilder withLastName(String lastName) {
          person.setLastName(lastName);
          return this;
      }
  
      public Person build() {
          return person;
      }
  }
  </code></pre>
  
  <p>I understand this may be an opinion based question, I was just looking for any answers as to why this may be a bad or better design pattern.</p>