Last active
August 29, 2015 14:23
-
-
Save FriendlyTester/70e39dab19f1260a20e3 to your computer and use it in GitHub Desktop.
A simple model for demonstrating the data builder pattern
This file contains hidden or 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 User | |
{ | |
private String firstName; | |
private String surname; | |
private int age; | |
private String emailAddress; | |
} | |
//Then you could do the following | |
public void setFirstName(String firstName) | |
{ | |
firstName = firstName; | |
} | |
//Repeating for all the properties. | |
//Most IDEs will auto generate this for you now adays | |
//Or if you are using Java, you could take advantage of lombok, https://github.com/rzwitserloot/lombok | |
//Would look something like this | |
@Getter @Setter | |
private String firstName | |
//lombok would then create the getters and setters for you. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment