Search word in multiple files
Semantic of methods

The implementation or the signature of the method "int getCount(String term);" does not make sense. Either you delegate the parameter "term" to the search algorithm with a stateless implementation or you omit it and have a stateful implementation. In the last case your "term" should be given to the constructor. I prefer a stateless implementation and all further comments are related to that.

Programming using interfaces

You are not using the interface "WordSearch". The assigment

BruteForceSearch bSerch = new BruteForceSearch(file);


be to the abstraction:

WordSearch search = new BruteForceSearch(file);


Avoid passing working list references

The code

Set&lt;File&gt; list = new HashSet&lt;File&gt;();
search.getFiles(folder, list);


should be refactored to:

Set&lt;File&gt; list = search.getFiles(folder);


The "List" should be instantiated within the method "getFiles(...)".

Make directory recursion part of WordSearch through template pattern

Currently you are collecting all files recursively within the main-method. Make the algorithm part of the WordSearch objects. To do so, refactor the WordSearch-Interface to an abstract class and implement the directory recursion as a Template Method.

public abstract class WordSearch {

    ...

    public int getCount(String term) {
        File folder = ...;
        return getCountInFolder(folder);
    }

    /**
     * Template method pattern
     */
    protected abstract int getCountInFile(File file, String term);

    private int getCountInFolder(File folder, String term) {
        int count = 0;
        File[] files = folder.listFiles();
        for (int j = 0; j &lt; files.length; j++) {
            if (files[j].isDirectory()) {
                count = count + getCountInFolder(files[j], term);
            } else {
                count = count + getCountInFile(files[j], term);
            }
        }
        return count;
    }

    ...

}


Introduce strategy pattern

Associate a WordSearch-Object within "Searcher" and delegate to it. This is called Strategy pattern.

public class Searcher {

    private WordSearch wordSearch;

    public Searcher(String dir, WordSearch wordSearch) {
        this.wordSearch = wordSearch;
        ...
    }

    public int getCount(String term) {
        return this.wordSearch.getCount(term);
    }

    public void setWordSearch(WordSearch wordSearch) {
        this.wordSearch = wordSearch;
    }

    ...

}


The WordSearch-Object may be set through the constructor and changed by a setter.