Skip to content

Instantly share code, notes, and snippets.

@rpocklin
Created August 22, 2011 23:19
Show Gist options
  • Save rpocklin/1163902 to your computer and use it in GitHub Desktop.
Save rpocklin/1163902 to your computer and use it in GitHub Desktop.
simplifying code (from Java to groovy or ruby)
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