回到这个程序,我发现目前的封装不在一个抽象层次上,更理想的设计是:
main() {
String words = read_file('words.txt')
String output = word_frequency(words)
print(output)
}
word_frequency(words) {
String[] wordArray = split(words)
Map<String, Integer> frequency = group(wordArray)
sort(frequency)
原文转自:http://www.jianshu.com/p/62f16cd4fef3