Take the 2-minute tour ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

This code is just a simple idea which takes a query parameter and requests n number of third party services for the given query:

public class SearchInteractor {
  private List<Service> services;
  private String query;
  private List<String> result;

  public SearchInteractor(String query, List<Service> services) {
    this.query = query;
    this.services = services;
  }

  public String[] search() {
    result = new ArrayList<String>;
    for (Service service: services) {
      result.add(service.search(query));
    }
  }
}

I am thinking of injecting a query and services in the search method. What do you think?

share|improve this question

closed as off-topic by Vogel612, Ismael Miguel, rreillo, BCdotWEB, Quill Aug 24 at 10:11

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions containing broken code or asking for advice about code not yet written are off-topic, as the code is not ready for review. After the question has been edited to contain working code, we will consider reopening it." – Vogel612, Ismael Miguel, rreillo, BCdotWEB, Quill
If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 1

I gave some thought and I think since its a just a service hence ideally it should be stateless.

public class SearchInteractor {   
  public List<String> search(String query, List<Service> services) {
    List<String> result = new ArrayList<String>;
    for (Service service: services) {
      result.add(service.search(query));
    }

    return result;
  }
}
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.