So a have a class called Dictionary. And one of its' method is
public boolean isRight(String word);
which searches if the word is in the collection of words (that's encapsulated).
private Set<String> rightWords;
So, I want to benchmark different types of searches that's why inside of this method I try to apply Strategy pattern.
public boolean isRight(String word){
Strategy st = new FastStrategy(word);
st.search();
// else...
}
So, since I should look through the rightWords variable should I pass it through the constructor of strategies or there is some better way to reduce a cohesion between to classes or it's ok. Also if I pass in a dependency to a strategy does it remain a strategy pattern?
Aucun commentaire:
Enregistrer un commentaire