Created
February 7, 2022 19:04
-
-
Save lukasjakobi/e9514360681d03bff82b3971cb0cb0f5 to your computer and use it in GitHub Desktop.
Builder Pattern Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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