Created
January 7, 2013 19:37
-
-
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
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 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