Suppose there is a class
class Stock
{
String id;
String name;
}
I want to create two comparators that are compared by id
and name
, respectively. Are there naming conventions or best practices for comparators in Java?
Are the following names available?
StockByIdComparator
and StockByNameComparator
SortStockById
and SortStockByName
I know that redundant names are excluded in certain areas. One could choose
List<Stock> stocks
over List<Stock> stockList
. Also, types should not be encoded in variable names (possibly since the advent of the IDE?). But there is an important dimension of clarity.
So what's good apraach to mean comparators?
source
share