Created
August 22, 2011 23:19
-
-
Save rpocklin/1163902 to your computer and use it in GitHub Desktop.
simplifying code (from Java to groovy or ruby)
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
Ruby / Groovy | |
def get_types | |
words.collect{|word| word.word_type} | |
end | |
15 seconds to code. | |
3 seconds to read and understand. | |
Easy to read = self documenting. | |
Less LOC = better codebase and more agile team. | |
Java | |
public List get_types { | |
List<String> word_types = new ArrayList<String>(); | |
for (Word: word : words) { | |
word_types.add(word.getWordType()); | |
} | |
return word_types; | |
} | |
1:10 seconds to write. | |
8 seconds to read... harder to interpret. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment