Getting products for category I have a PR for a bugfix in which the fix is just 4 characters. In this situation we are invited to make some refactoring on the class that we are touching if possible.

Venkat Subramaniam's advice is to make lambda expressions just one line, hence I'm trying to move a block of code in a method.

Now choosing a better name come to the scene, and the challenge is to use For+ParamName or not use it on the method name.

With this advice from Google folks (Code Health: IdentifierNamingPostForWorldWideWebBlog):


  Omit words that are clear from the surrounding context.


I think that a method name getProducts(Category category) is better than getProductsForCategory(Category category), so could we avoid the For+ParamName? 

Before

public class ProductProvider {

private final ProductProviderDatabaseHelper databaseHelper;

public ProductProvider(ProductProviderDatabaseHelper databaseHelper) {
    this.databaseHelper = databaseHelper;
}

public Observable&lt;List&lt;Product&gt;&gt; getProductsForCategory(Category category) {
    if (category == null) {
        return Observable.just(Collections.emptyList());
    }

    return Observable.defer(() -&gt; {
        List&lt;Product&gt; result = new ArrayList&lt;&gt;();

        try {
            // DAO code
            result = daoProduct.query(preparedQuery);
        } catch (SQLException e) {
            Timber.e(e, "Error retrieving Products");
        }

        return Observable.just(result);
    }).subscribeOn(Schedulers.io());
}


After

public class ProductProvider {

private final ProductProviderDatabaseHelper databaseHelper;

public ProductProvider(ProductProviderDatabaseHelper databaseHelper) {
    this.databaseHelper = databaseHelper;
}

public Observable&lt;List&lt;Product&gt;&gt; getProductsForCategory(Category category) {
    if (category == null) {
        return Observable.just(Collections.emptyList());
    }

    return Observable.defer(() -&gt; getProducts(category)
    ).subscribeOn(Schedulers.io());
}
The method name getProducts looks like a getter. However, there is some logic inside and getters usually don't have arguments. getProducts(Category category) seems a bit suspicious for me.

The name getProductsForCategory(Category category) looks too verbose: category is present three times. Why not calling it getProductsFor(Category category)? There would be no repetition and it is read straightforward.

To avoid the confusion with a getter, I also think that it could be named filterProductsBy(Category category) or retrieveProductsFor(Category category).