Skip to content

Instantly share code, notes, and snippets.

@lukasjakobi
Created February 7, 2022 19:04
Show Gist options
  • Save lukasjakobi/e9514360681d03bff82b3971cb0cb0f5 to your computer and use it in GitHub Desktop.
Save lukasjakobi/e9514360681d03bff82b3971cb0cb0f5 to your computer and use it in GitHub Desktop.
Builder Pattern Example
public class Main
{
public static void main(String[] args) {
// what do all these parameters mean?
Account account = new Account(1, "Otto", "Päde", 50, "Haselnussstraße", 0, null, "user", false);
// or with builder pattern
Account account = new AccountBuilder()
.withId(1)
.withFirstName("Otto")
.withLastName("Päde")
.withStreetNumber(50)
.withStreet("Haselnussstraße")
.withRank("user");
// leave out all the default values
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment