Created
September 7, 2013 15:26
-
-
Save spencerwi/6476557 to your computer and use it in GitHub Desktop.
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
// BAD: | |
List<PersonEntity> pes = someFetcherFunction.findByAgeGreaterThan(18); | |
if (pes.contains(currentPE)) { return "Hello, sir/madam."; } | |
else { return "This method is for adults only!"; } | |
// GOOD: | |
static Integer LEGAL_ADULTHOOD_AGE = 18; // in class PersonEntity | |
//... | |
List<PersonEntity> listOfKnownAdults = someFetcherFunction.findByAgeGreaterThan(PersonEntity.LEGAL_ADULTHOOD_AGE); | |
if (listOfKnownAdults.contains(personBeingCheckedForAdulthood)) { return "Hello, sir/madam."; } | |
else { return "This method is for adults only!"; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment