I have a SearchService which uses an algorithm for querying a database and returing the results. There are a couple of different formats the data can be returned as, depending on what the invoker wants from the service. These formats are:
- A list of entities that directly match against a table in the database
- A list of primary keys (Longs) of the records that match
- A list of ‘search results’ which is composed of a bunch of fields that are generally relevant to what a user would want to see from a search result (say a persons name, address phone number etc)
Currently my SearchService looks like:
public interface SearchService {
public List<People> searchPeopleReturnEntity(SearchRequest request);
public List<Long> searchPeopleReturnId(SearchRequest request);
public List<SearchResult> searchPeopleReturnSearchResult(SearchRequest request);
}
I’m looking for advice on best practices regarding this. Currently the naming convention seems pretty clunky and I believe there is a better solution than what I have now.
I’d call them
findPeople(),findPeopleIDs()andfindPeopleResults().