Skip to content

Instantly share code, notes, and snippets.

@spencerwi
Created September 7, 2013 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spencerwi/6476557 to your computer and use it in GitHub Desktop.
Save spencerwi/6476557 to your computer and use it in GitHub Desktop.
// 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