CMPUT 301

Software Engineering

Class Participation Exercise: Template Method Pattern (Mar 26)


Class Participation Exercise: Template Method Pattern

Rewrite countWords() * Convert the countWords() method to a template method using the Template Method Pattern, removing the conditionals.

Write code for one of the following subclasses: * RawWordCounter * WordCounterNoStopWords * LowerCaseWordCounter

public class WordCounter {
...
void countWords() {
    loadData();
    if (lowerCaseWords) {
        lowerCaseData();
    }
    if (removeStopWords) {
        filterStopWords();
    }
    calculateTermFrequency();
    calculateTermDocumentFrequency();
    saveCountData();
}
}