I'm trying to learn better software design and recently found the Repository and Service Layer patterns. From my understanding, the repository basically contains the data access code and the service layer calls the repository to get that data and then performs some logic and processing to that data.
So far from reading up on these there is, generally, not a set series of methods that the repository has. However, the repository usually has methods along these lines:
- List/Get/Read/etc.
- Create
- Save
- Update
- Delete
I'm trying to understand the naming conventions for repositories. What should I call the "List/Get/Read/etc." method? I'll give an example.
I'm currently working on a project that will read from a bunch of directories and files. These files represent sensor readings that are being generated by a completely separate and already existing system.
Should method names be specific to that particular type of repository or go for more generic sounding names? Such as:
Generic names:
interface ISensorRepository
{
IEnumerable<Sensor> GetAll(); / IEnumerable<Sensor> ListAll(); / etc.
Sensor GetByID(int id);
}
Entity specific names:
interface ISensorRepository
{
IEnumerable<Sensor> GetAllSensors(); / IEnumerable<Sensor> ListAllSensors(); / etc.
Sensor GetSensorByID(int id);
}