Reputation: 9365
I have this abstract class that is used as data repository.
public abstract class AbstractDataSource {
public abstract DataRow getDataRow(Key key); //or just dataRow(Key key)???
}
public class CSVDataSource extends AbstractDataSource {
@Override
public DataRow getDataRow(Key key) { //or just dataRow(Key key)??
//fetch row from file and return dataRow
//....
return dataRow;
}
}
More specific classes (i.e. subclasses of this class) implement methods for different data source, e.g. CSV, ARFF and other formats.
I was wondering if the "get"-Keyword is appropriate here, as the data retrieval is not just returning a variable, but could also require filesystem access or whatsoever.
So should I use the "get"-prefix or not?
Thanks
Upvotes: 9
Views: 2921
Reputation: 31848
Do you want to this method to be a bean getter, so you can use it with things like BeanUtils? Given that it is doing heavy I/O and some logic, probably not, so I would name it differently.
Upvotes: 2
Reputation: 49187
I agree that using the get
keyword can sometimes seem non-intuitive when there's real logic behind. In your case lookup
or find
prefixes could be good substitues. There's also retrieve
as suggested by @Thomas.
This question might seem off topic at first. But naming is, at least to me, an integral part of good application design.
Upvotes: 10