Skip to content

Instantly share code, notes, and snippets.

@djleeds
Created January 7, 2013 19:37
Show Gist options
  • Save djleeds/4477727 to your computer and use it in GitHub Desktop.
Save djleeds/4477727 to your computer and use it in GitHub Desktop.
Demonstrates variable and method names that align better with the abstraction level of the code. Copyright (c) 2012 Lampo Licensing, LLC and released under the MIT license
public Address findAddress(String city) {
Address matchingAddress = null;
List<Address> addresses = getAddresses();
for(Address address : addresses) {
if(address.getCity().equals(city)) {
if(matchingAddress == null) {
matchingAddress = address;
} else {
throw new RuntimeException("Found multiple matching addresses.");
}
}
}
return matchingAddress;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment